A toggle is a button or switch that can be pressed to select between two states or options. It’s used in technology, computing, programming and communications to give users a way to control what features they want active or not.
You’ll find toggles in everyday technology like your smartphone or tablet, allowing you to enable or disable WiFi and Bluetooth. They’re also often used in software to enable or disable features like video streaming or location services. In more recent times, the toggle has become an important part of web development and accessibility tools to allow developers to make content visible or invisible based on user preference or needs.
The use of toggles is popular in the tech world due to the agility and speed they provide for developers. But it’s essential to use toggles carefully to avoid creating bugs that may be hard to track and fix down the line.
Using toggles to add features to a production system can increase the number of database calls in your codebase. Each time a toggle is activated it causes a database query to fetch the toggle state from a database table, which can lead to thousands of queries if you have many toggles. This can cause a degradation of performance for your production system.
This can be avoided by using toggles sparingly, adding new features with care and implementing a process to clean up the toggles when they are no longer needed. If your team is going to use toggles in a major project, they should be vetted by the leadership team for impact and risk to ensure that they are used appropriately.
Toggles are commonly used to implement A/B testing in ecommerce systems. They’re also sometimes used for minor features that can be turned on or off in the case of a bug. However, I think it’s a better idea to decide on a case-by-case basis whether a toggle is necessary for a bugfix.
Our ecommerce company is debating which algorithm to choose for their configurator. They create an experiment toggle that splits users into two cohorts and sends them down one of the two different suggestion algorithms, allowing them to compare which one performs better. After three weeks the team has enough data and can confidently choose to deploy algorithm B to all users.
Using feature toggles allows your development team to release new features even while the new functionality is still in the works. This is much faster than the traditional waterfall development process where these features would need to be written on a separate code branch and then integrated into trunk code.