1

Lets say I have library "A2" as a dependency in a project. Library "A2" is derived from library "A1"(A2 is a fork of A1 with some modifications to the original source code) where someone has done few changes to the library "A1" 's source code.

Lets say there is a new version of "A1" I want to use the new version but no modification to its sourcecode at all.

I am planning to identify what are the changes done to the original library when deriving library "A2" out of it and decorate the latest version of the library with those changes. Is it a good approach to solve this? if not can someone suggest the best approach to solve this kind of problems?

closed as unclear what you're asking by Robert Harvey, Doc Brown, user40980, GlenH7, jwenting Jun 10 '14 at 11:22

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    What problem is it that you're trying to solve, exactly? – Robert Harvey Jun 6 '14 at 3:56
  • I want to use the latest version of the reference implementation. But still need to support derived functionalities in A2 without doing source modification of the latest library version. – Kanishka Dilshan Jun 6 '14 at 4:05
  • 1
  • 2
    What do you mean by "A2 is derived from library A1" - do you mean A2 links against A1, or do you mean A2 was created as a fork of A1, with some changes to the original source? And when you say "but no modification to its sourcecode" - do you mean you want to keep A1 unmodified and link A2 against the new version of A1, or do you mean you want to create a new fork "A2 V2" of "A1 V2"? Please edit your question and clarify, otherwise I would not be surprised if your question will be closed soon by the community. – Doc Brown Jun 6 '14 at 6:01
  • 4
    Are both A1 and A2 libraries maintained by third parties, or are you also maintaining one of them? – Bart van Ingen Schenau Jun 6 '14 at 8:05
3

Is it a good approach to solve this?

Well, it is most probably not a good way, but your only reasonable choice to solve this in the given situation. But expect this happen again when version V3, V4, V5, ... of lib A1 will be released - as long as you don't take any additional measures, you will always have the effort of merging the A2-changes into the code of A1. If A2 differs only very slightly from A1, and the changes are well documented, that may be fine. Proper use of a version control system or at least a diff-merge tool for generating a patch-set for A1->A2 can also be helpful (at least, when A1 does not change from version to version so much that your patch-set cannot be applied any more).

The better alternative would be to contact the author of A1 beforehand and ask him kindly if he can change A1 in a way that you won't need to the fork in the future any more. He might consider integrating some of the additional features from A2, or (if that is not reasonable) to change the interface of A1 in a way so it will allow the adding of extensions without the need for changing A1. The goal should be to build A2 as a separate library which just links A1, unmodified. Maybe he can provide a "hook" or "plugin" mechanism, or maybe just make some internal methods public, this depends completely on the design of A1 and your requirements for A2.

Not the answer you're looking for? Browse other questions tagged or ask your own question.