Feature Toggles and Variability

Features toggles are an idea gaining traction lately, used in continuous delivery. This post discusses the similarities they bear to implementing variability in software product line engineering.

(image by wayne wilkinson)

The idea is to ‘toggle’ on or off certain features in a user interface, to allow for partially completed features to be worked on while keeping the code always integrated. They’re an alternative to feature branches, where a developer will go off for a week or two on a separate branch, only integrating it when finished. As Jez Humble has said “your code is useless until it’s integrated.” With feature toggles incomplete features can be included and released to production code. They’re just hidden away until they’re ready to be rolled out.

To me the ideas involved aren’t that disimilar to managing variability within a software product line. In fact as Martin Fowler states “Feature toggles can be used for permanent variable configuration too, such as different versions of a software for different contexts.”

This gels perfectly with software product lines, where different products within the product family are different configurations of the product line.

As Fowler goes on to say:

“This is a different use to handling pending features but most of the implementation is the same.”

The implementation techniques mentioned by Fowler are:

  • For turning off certain pieces of functionality in the UI…
    • simple on or off ‘toggle’ tags which are tied to a configuration option
    • really just a conditional in UI markup
  • Where there are no UI elements, the toggle test is in the application code.
    • It can be as simple as a conditional test
    • Or something more sophisticated “like a strategy wired through dependency injection.”

These techniques are mentioned in the SPLE literature. I’d say the SPLE literature goes a bit more (overly, painstakingly…) detailed than this. But it’s interesting to me that these are the options most commonly observed being used by Fowler. It suggests they’re the most practicable.

The salient point for me is that approaches used for implementing feature toggles can also be looked at as ways of implementing variability in product line engineering. Much as with multi-tenant software and product lines, it’s always interesting to see these crossovers. And as the software engineering community often has more practical, easily appliable advice than the high-level theory papers of the academic community, I’m looking forward to investigating feature toggles further.