Tuesday, August 24, 2010

Why Distributed Revision Control increases Agility

I recently did a talk about practices we have introduced to make us more agile.

At the end of the presentation, I mentioned distributed revision control as one of the next practices we want to do. Now how on earth does using Git or Mercurial increase our agility?

The short answer is: Feature Branches.

The long answer is...

We have a defined agile as among other things, this value: Ship working software.

This value implies that we keep the mainline of the code (known to many as the stable branch) in a working state. A good way to keep it that way is by making sure that only safe changes make it into the mainline. If you've got developers continuously working on the mainline to create new features piece by piece, chances are the code is in a broken state every now and then.

In order to remedy this, lots of companies (including ours) have decided that the team should maintain two versions:

  • one experimental, where new features are developed, and 
  • one stable, which should always be in a working state. 

This is a bit of an expensive practice, because you end up with long rounds of verification before the experimental branch can be released, replacing the stable version. You also have to continuously merge back bugfixes from the stable branch to the experimental branch.

So, the idea of feature branches is to keep new development out of the way until it is ready to go out in the mainline. When the feature is complete, you test it well. You then merge the feature into the mainline, do some quick verification that it is still in a working state, and then you release. Much smoother (agile) than releasing an entire experimental branch.

So feature branches are agile. Why don't we do more of those?


The problem is Subversion, or whatever other centralized VCS you're stuck with. They do not allow easy/cheap merging between branches (and I don't want to hear about that half-assed merge-tracking svn-properties hack), and therefore feature branches are practically impossible.
.
You might argue that Subversion users can  keeping their changes locally in the workspace, but there's a major constraint: They can't collaborate on their feature. This means missing out on a lot of co-operation, creative process, ideas, code-review and refactoring before the feature ends up in the mainline. They could operate with sending patches around, but at some point it's time to ask how much hassle you have to take before you replace your malfunctioning VCS with a proper one.

At this point, I would like to outsource the illustration of how you can do feature branches in practice to the very fine illustration from Vincent Driessen. He has really nailed it, I think. In his model, what I've called mainline, or stable, he calls "master", and what I've called experimental, he calls "develop". The release branches also serve as nice points for setting up Continuous Integration (cause you probably don't want to set up CI for every single feature-branch).

So, summary: 


Distributed Revision Control allows you to do feature branches, keep the software in a working state, and ship one feature at a time. In other words, more agile.