Soroush Khanlou ( tweet ):
A problem presents itself. You have to build a function that takes 1000 lines of code, but you want to melt it into smaller pieces. How can you merge the code if it's not done?
The strategy is basically called the "branch of abstraction". You "branch" your code base, not using git branches, but rather branches in the code itself. There is no way to make the branch abstraction, but many techniques are all useful in different situations.
Of course, the humble
if the phrase is also a great way to use this technique; Use it with flags to turn on and off functions. (A feature flag doesn't have to be complicated. A global constant boolean gets you pretty far. Function flags don't have to come from an external source! But I would recommend against compilation time
well be dead.)
Branches are just not very useful for handling features or large releases that the development will last for a long time (during which you will continue to work on the freight version). They are great when you want to make a bug fix based on an old version, and then plan for the branch to die. But otherwise you spend a lot of time merging changes back and forth between two active branches and still end up with a potentially difficult integration at the end. It is better to use feature flags and potentially additional Info.plist files and Xcode targets to support simultaneous development of multiple versions.
Stay updated by subscribing to comments RSS feed for this post.