Sunday, June 11, 2017

Gettting rid of hell of code merge

If I asked you to list down what are your most awkward moments in software development life cycle that you are facing, you definitely list merging codes as the top most item. Since our code merge tools are not intelligent enough to perform semantic code merging, almost all the tools fail to merge two source code file where more than one developer has changed on the same line on the same file. We can hope that in future there will be tools to address the issue, but for now, we have to admit that.

Is that all we can do?

It is true that we can not totally get rid of the merge hell but we can take some measures to reduce the complexity. I've seen teams consume more time to merge their code than it took for the actual development. So what are the factors that determine how complex your code merge?

Basically, there are two.
  • The size of the code chunk that you are about to merge.
  • The time gap between the last merge.


complexity = size * duration.

If you need to reduce the merging complexity, then you have to reduce the both factors. In continuous integration we often say, integrate frequently with non-breaking code chunks.

In reality, it is not easy to commit small code chunks frequently that are not breaking anything or any others work. Usually, developers wish to isolate their work from others. If you are a git lover you have branches, if you need deep isolation you choose forks. It's good to be isolated but some point you are in big trouble.

Hassle-free integration.

You are not the first victim of this issue, most of the organisations have struggled with this and tried out new approaches to this address this merge complexity. Trunk based development aka TBD is an approach that successfully adopted by industry giants which encourage teams to work on a single branch(trunk) which leads less code merge problems and introduce plenty of new problems. However, it is worthy to try this approach since so we are soo fed up with huge merges.

for more info:

https://trunkbaseddevelopment.com/