A toggle is a switch with two positions, on and off. You can use a toggle to alternate between screen displays during a video chat with two friends at once, or to turn on and off your laptop’s Caps Lock and Num Lock keys. Software developers use the term toggle to refer to a piece of code that controls whether specific features are enabled or disabled. This type of code is sometimes referred to as a “feature flag” but we like to use the term toggle because it’s clearer that a toggle is meant for temporary use only and that it is not intended to replace a more robust distributed configuration system.
Savvy teams think of the toggles in their codebase as inventory that comes with a carrying cost and they try to keep it low by being proactive about removing toggles as soon as they are no longer needed. Occasionally, though, an operation toggle will need to stay active for a few weeks or even months to provide some extra resilience during a high-traffic period. If this is the case, it’s a good idea to add some extra validation that clearly states that the toggle will remain in its current state until it’s manually disabled again.