What is a Toggle?
Toggle is a term that refers to a switch with two positions, on and off. It can be found in the hardware world with toggle switches such as the caps lock or num lock keys on keyboards or in software when a function is switched between active and inactive. The word has also become an adjective that describes an activity such as juggling multiple screens as you video chat with friends or toggling between stream and map views on Google maps.
A key benefit of using toggles to manage features is that this configuration lives side-by-side in source control. This provides a lot of flexibility and helps teams to rapidly test their work. For more dynamic toggles such as those used in experimentation or to support A/B testing this can reduce the amount of re-deployment required to validate new code changes. This can help speed up the process of getting feedback to developers and allowing them to deliver more quickly.
Another way that toggles can be beneficial is in supporting agile development approaches by allowing dev teams to deploy features before they are ready for wider release. This can be done by deploying the feature to a select group of users and then using a toggle switch to allow them to activate it when they feel that the feature is complete enough for broader release. This can allow a team to deliver features even when they are not fully baked and can give the business value of the feature while still meeting delivery deadlines.
As the use of toggles becomes more commonplace, there are a number of best practices that should be followed to make it as easy and productive as possible. A good place to start is to clearly label each toggle and make sure that the label explains what will happen if the toggle is switched on. This may seem obvious but is often overlooked. The best labels are short and direct, they should convey what the feature will do if it is enabled.
It is also helpful to have a clear process for identifying when a toggle should be pruned and removed from the codebase. This can be done by adding a task to the team’s backlog or by building this process into your management platform. Savvy teams view the inventory of idle toggles as having a carrying cost and strive to keep this level as low as possible.
Some teams go as far as to put “expiration dates” on their toggles so that a process will fail or not run if the toggle has not been updated in a set time period. This can be a very effective way to prevent old code from hanging around for years after it is no longer needed.