A toggle is a switch that has two possible states, On or Off. It can be found in almost every aspect of computing, from the caps lock key on your keyboard to the buttons on an ecommerce site.
The word toggle is derived from the Latin verb tog*gle, meaning “to fasten with a pin” or “to bind”. Toggles are often used in connection with ropes or chains, but they can also be applied to other devices such as a light switch, a batten for strengthening a frame, or a metal device that inserts into a buttonhole.
Toggle Configuration
The simplest way to manage toggle configuration is to hardcode the settings for each feature flag into a static file. This is usually a good strategy, but it does come with some limitations and can become very complex when the number of toggles grows.
Runtime Config
Some toggle configuration systems offer a dynamic in-memory re-configuration mechanism that allows toggles to be changed in the process of running tests. This is very useful in cases where a feature flag is being tested as part of an ephemeral environment, such as an automated test or a test script.
This approach is a little more complicated than the commenting solution but offers a much better chance of ensuring consistency across a wide range of toggles. It also gives a little more flexibility to teams who wish to add new features that may require re-configuration of a toggle as part of their build process.
Experiment Toggles
An Experiment Toggle is a type of feature flag that can be flipped On or Off during testing of a system. This lets a team perform a series of multivariate or A/B experiments on the system to test how different codepaths affect the behavior of a set of users.
These experiments can be used to make data-driven optimizations to the system. The results from these experiments are recorded and made available for analysis in a later phase of the project.
When a release is in development, it’s always a good idea to perform some type of test on the toggle configuration which will be used as live in production when that toggle is flipped On. This test is especially helpful when there are a large number of toggles which will be flipped On in a future release, as it will give the team a feel for how these toggles might behave.
Removing Toggles
Savvy teams view their toggle inventory as something that comes with a carrying cost and seek to keep it as low as possible. In order to do this they proactively remove toggles that are no longer needed, either as a rule of thumb or by setting an expiration date.
Having to manually remove toggles from the production environment can be difficult and a bit fiddly, particularly when it is necessary to do so for product-centric toggles. For this reason many teams move toggle configuration into some kind of centralized store, generally an existing application DB. This can be accompanied by a build-out of some form of admin UI which gives system operators, testers and product managers access to the configuration store.