What is a Toggle?
A toggle is a switch that can be flipped between two positions. This is common in software with options and preferences menus and also is seen in hardware devices like a cordlock toggle for stopping a drawstring.
Toggles are used to update preferences, settings, and other types of information. They are a great tool for making changes quickly and easily. When using toggles, ensure that they are clearly labeled and utilize visual cues (i.e. movement and color) to avoid confusion. In addition, it is important to evaluate the societal and cultural implications of the toggle’s colors (i.e. red for “on” versus green for “off”).
The word toggle comes from the 18th century definition of pin passed transversely through an eye or loop in a chain or rope to fasten it temporarily. It is still used for that type of fastener and has since been applied to a variety of hardware and software switches. In computer technology, a toggle is an on-off command that can be enabled and disabled with the click of a button.
Generally speaking, a team should always test the toggle configuration that they expect to see in production. This includes testing the fallback configuration with all toggles flipped Off. It is also wise to test with the toggles flipped On as well in order to catch regression bugs.
Another aspect of Feature Toggle configuration that can be challenging is when a toggle’s configuration needs to change at runtime. For example, a team might need to change the codepath that a user takes based on their cohort status. To do this, the team may need to re-deploy the code and change the toggle’s configuration. This can be time consuming and slow down the feedback loop that CI/CD is supposed to provide.
This is often why many teams choose to move their toggle configuration into a centralized system, like an existing application DB or some form of admin UI. This approach allows for a more dynamic toggle configuration and eliminates the need to re-deploy and retest in order to change the configuration of a flag. However, some teams are reluctant to do this because they feel that it introduces a lot of additional complexity into the system.