Saturday, October 30, 2010

Experience Report: Feature Toggle over Feature Branch

We often use Feature Toggle on my current team (when gradual release isn't possible). My experience so far has been: gradual release is better than Feature Toggle, and Feature Toggle is better than Feature Branch.

I found Martin's bliki entry on Feature Toggle to be a great description, but the entry doesn't touch on the primary reasons why I prefer Feature Toggle to Feature Branch.

When using Feature Branch I have to constantly rebase to avoid massive merge issues, in general. That means rebasing during development and testing. Rebasing a branch while it's complete and being tested, has often lead to subtle, merge related bugs that go unnoticed because the feature is not under active development.

Additionally, (and likely more problematic) once I merge a feature branch I am committed (no pun intended). If a bug in the new feature, that requires rolling production back to the previous release, is found after the branch has been merged I find myself rolling back the feature commit or continuing with a un-releasable trunk. Rolling back the commit is painful because it is likely a large commit. If I continue on with an un-releasable trunk and another (unrelated to the new feature) bug is found in trunk I'm in trouble: I can't fix the new bug and release.

That's bad. I either lose significant time rolling back the release (terrible), or I roll the dice (terrifying). I was burned by this situation once already this year. It is not something I'm looking to suffer again in the near future.

Feature Toggle avoids this entirely by allowing me to run with the toggle available and turn it back on if things go wrong. When I feel comfortable that everything is okay (usually, a week in prod is good enough), I clean up the unnecessary toggles.

Of course, nothing is black & white. Sometimes a Feature Toggle increases the scope of the work to an unacceptable level, and Feature Branch is the correct decision. However, I always weigh the terrible/terrifying situation when I'm choosing which direction is optimal.

It's also worth noting, I roll the current day's changes into production every night. It's possible that your experience will be vastly different if your release schedules are multi-day or multi-week.

4 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This may be a bit off-topic, but in the past we've left certain feature toggles available to allow for graceful degradation, gradual feature roll-out, instant roll-back, and selective activation. For some features, the impetus to use feature toggle over feature branch largely stemmed from its side-benefits rather than the necessity to both isolate and integrate evolving code.

    ReplyDelete
  3. Another advantage of toggle over branch is that the capability of your repo tool (e.g. git, svn) doesn't affect the implementation of a toggle (it may affect your decision vs using a branch though)

    ReplyDelete
  4. Anonymous7:47 AM

    Hi Jay,

    Thought you might be interested in this CodePlex project which is offering simple implementation at the moment :)

    ReplyDelete

Note: Only a member of this blog may post a comment.