Uncategorised

What is a Toggle?

A toggle is a pin, rod or crosspiece fitted or inserted into a loop in a rope, chain or strap to prevent slipping, to tighten it or hold an attached object. The word is also used figuratively to describe a switch between two or more electronic, mechanical or computer-related options — for example the key that turns Caps Lock on and off on a keyboard is a toggle.

In software development a toggle is a configuration option that can be either ON or OFF and provides the means to alter an existing feature. Most software applications provide a way for users to select the toggle state they want their settings to be in (similar to a checkbox). Generally speaking it’s preferred to use a toggle to adjust system settings or preferences rather than a drop-down menu as it takes up less screen real estate and is easier to read.

Savvy teams view their Feature Toggles as inventory that comes with a carrying cost and seek to minimize the number of toggles in their codebase. To that end many teams have a policy of adding a toggle removal task to the team backlog whenever a new Toggle is introduced and some go so far as to put expiration dates on their toggles so that tests will fail if they haven’t been flipped off before an expiration date passes.

Another common use of toggles is to perform multivariate or A/B testing. By using a Toggle Router to change the code that is sent to a particular cohort at runtime it’s possible to see how different codepaths affect user behavior. This is especially useful for improving Call To Action or conversion copy.

Toggle configuration can be stored in static files but if the toggle is a runtime switch then it’s preferable to use some type of distributed configuration system which allows for dynamic in-memory re-configuration of specific service instances. This eliminates the need to restart a process in order to flip a toggle and allows for much more rapid validation cycles within the CI/CD pipeline.