Definition of feature flipping
A feature toggle is a point in the code where the software chooses, at runtime, between two behaviours. Feature flipping refers to the use of these toggles to turn a feature on or off. The term comes from usage. The sources consulted for this entry say feature toggles or feature flags. The article “Feature Toggles (aka Feature Flags)” by Pete Hodgson, published on martinfowler.com, treats these expressions as synonyms, as it does “Feature Bits” and “Feature Flippers”, and sees in them a technique that makes it possible to modify a system’s behaviour without changing its code.
The OpenFeature documentation (openfeature.dev) reduces the simplest case to an if/else statement controlled at runtime.
Deploying is not releasing
Deploying installs code in production; releasing opens it to users. Pete Hodgson’s article links toggles to this principle of continuous delivery: separating the release of a feature from the deployment of the code. Work in progress can then join the shared branch before it is finished, since the delivered code remains inactive. The automated pipeline this practice requires is presented in our entry DevOps.
Four categories of toggles
The author classifies toggles along two dimensions: their longevity and the dynamism of the decision.
| Category | Use | Lifespan indicated by the article |
|---|---|---|
| Release toggle | Delivering unfinished code, left inactive | Transient: generally not much more than one to two weeks |
| Experiment toggle | Assigning each user to a cohort for an A/B test | Long enough to obtain a significant result |
| Ops toggle | Disabling or degrading a function in production | Short, apart from a few long-lived “kill switches” |
| Permissioning toggle | Reserving a function for certain users | Long, sometimes several years |
The article likens long-lived ops toggles to a manually operated circuit breaker.
OpenFeature: a common evaluation interface
According to the OpenFeature documentation, full use of feature flags requires a dedicated management system. This specification, a project hosted by the CNCF, defines a common evaluation interface, independent of the system chosen.
Feature flipping, A/B testing, canary release: not to be confused
A/B testing is an experimentation method, which compares the behaviour of cohorts of users. The toggle is its mechanism, and a release toggle compares nothing.
A canary release opens something new to a small share of users, chosen at random. A toggle makes it possible to do so without redeploying. The article distinguishes it from opening to a selected group, for example internal users.
Textbook case: a tour operator’s new search engine
Take an online tour operator redesigning its holiday search engine. The new code goes into production behind an inactive release toggle. The team activates it for its own employees, then for a randomly chosen share of visitors, while monitoring response time and error rate. At general release, an ops toggle makes it possible to revert to the old engine in the event of overload.
One task remains, recorded from the outset: removing the release toggle and the old code.
The debt of toggles that are never removed
Each toggle adds a condition or an abstraction to the code, and a testing burden: according to the article, a release is validated with the toggle on and then off. The author speaks of a carrying cost and compares toggles to inventory, to be kept as low as possible. A forgotten toggle becomes technical debt.
The article cites several team practices: adding the removal task to the product backlog as soon as a release toggle is created, giving it an expiry date, making a test fail once that date has passed, capping the number of toggles in a system.
These toggles take their place in a delivery pipeline. How it is built, including canary release, is presented in our page DevOps and platform engineering.