What is a Toggle?
A toggle (also known as a switch or knob) is a piece of interface code that enforces a mutually exclusive state – either ON or OFF. Toggles are often used for settings, preferences and other configuration options. They are particularly useful in mobile apps, where space is limited and users can only afford to tap a button or two at a time.
Toggle is also a popular technique for implementing A/B testing and other data-driven optimizations. By separating your production system into cohorts and then routing each user down one of the two codepaths via a feature flag, you can measure which one has better results. You can then make data-driven optimizations to things like the purchase flow in an ecommerce app or even the Call To Action wording on a button.
Some teams choose to store their toggle configuration in static files or in the application config but once you get above a certain scale this can be cumbersome and difficult to manage. Instead, it is more common to move toggle configuration into some form of centralized DB or application config, often with a dedicated admin UI that can be used by developers, testers and product managers.
It’s a best practice to test the toggle configuration that is expected to become live in production, plus any future toggles that you intend to release flipped On. Many teams additionally test a fallback configuration where all toggles are flipped Off, so that no surprise regressions slip through the cracks in a new release.