Feature Toggles: Decouple Deployment from Release
A feature toggle is a runtime switch that lets you ship dormant code and activate it later, decoupling deployment from release. It enables canary rollouts and A/B tests.
THE MENTAL MODEL: Think of a feature toggle as a dynamic IF statement in your code that you can control from outside the application, even after it's deployed. It separates the act of deploying code from the act of releasing a feature. This allows you to ship incomplete or experimental features to production safely, keeping them hidden until they are ready.
HOW IT WORKS: At its core, a feature toggle is a conditional block of code. For example: if (featureIsEnabled('new-user-dashboard')) { showNewDashboard(); } else { showOldDashboard(); }. The featureIsEnabled function checks a configuration source—like a database, a remote service, or a simple config file—at runtime to see if the 'new-user-dashboard' feature should be active for the current user. This allows you to change the application's behavior without a new deployment.
WHEN TO USE IT: Feature toggles are powerful tools for modern software delivery. Three key use cases are: first, canary releases, where you enable a feature for a small percentage of users (e.g., 1%) to monitor for errors before a full rollout; second, A/B testing, where you show different feature variations to different user segments to measure impact; and third, operational control, where a toggle acts as a 'kill switch' to instantly disable a problematic feature in production without a full rollback.
WHEN NOT TO USE IT: Avoid using toggles for permanent configuration or architectural seams; they are meant for transient states during a feature's lifecycle. A toggle that lives for months or years is technical debt. It adds complexity, increases the number of code paths to test, and makes the system harder to reason about. For simple, low-risk changes, the overhead of a toggle might not be worth it. Always have a plan to remove a toggle once its associated feature is fully rolled out or abandoned.
ONE CANONICAL EXAMPLE: An e-commerce site wants to test a new, one-page checkout process against its existing multi-page flow. The team wraps the new checkout code in a feature toggle named 'one-page-checkout'. They configure their flagging system to enable the toggle for 10% of their users. By tracking conversion rates for both groups, they can gather data on which flow performs better. If the new flow is successful, they can gradually increase the percentage to 100% and then schedule work to remove the old code and the toggle itself.
Read the original → en.wikipedia.org
Get five bites like this every day.
Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.