Hello everyone!
In today’s blog post, we’re going to cover an incredibly important topic that will help you deliver software faster and in a safe way: feature flags.
We’ll see what they are, which are their benefits and disadvantages and how you can adapt them to your project,
What they are
A feature flag in software development provides an alternative to maintaining multiple feature branches in source code.
A condition within the code enables or disables a feature during runtime. In agile settings the toggle is used in production, to switch on the feature on-demand, for some or all the users.
Thus, feature flags make it easier to release often. Advanced rollout strategies such as AB testing are easier to handle this way.
What are their benefits?
- Reduce risk and recover faster
Experiencing errors, performance spikes or user backlash? Switch off features without redeploying code. Fail safer with rollouts targeted to a small percentage of users before launching at large. - Manage all features in one place
Stop managing rollouts in config files and tracking features in tedious spreadsheets. With them, you can release features quickly, easily roll back and enable collaboration so you can reduce the burden on development and QA. - Test rollouts on any device
Confidently roll out and test everything from new pricing on your website, push notifications on your mobile app to a new feature on your code.
Disadvantages
- Your codebase will probably grow: you’ll have the legacy code and the new code together and coexisting at the same time. Although this shouldn’t be a real problem, you need to make sure your codebase doesn’t increase so that it affects your project’s performance.
- Keep in mind the naming relationship between a feature flag and the concrete domain area: make sure you remember and store the name of the feature flags (and what they hide/show) in a safe place that only a selected amount of folks can change. Otherwise, anyone would be able to turn them on (or off) or won’t be aware of what the feature flag protects unless they have access to the code itself.
- Make sure you remove legacy code when the new feature’s been properly tested: another pitfall related to the usage of feature flags instead of git branches is that, once you deliver a new feature, it’s sometimes easy to forget to remove the legacy code of the code that is no longer necessary, but this should be in your to-do list so that your codebase is always up to date, refreshed and doesn’t contain old code for ages.
Adapt them to your project
Now that you’re aware of what their main benefits are and which pitfalls you should avoid by using them properly, you can start using them in your project.
We personally recommend the usage of tools like “unleash” that you can quickly add to your code (both in the frontend or backend) as a library, importing it in your code and creating a list of feature flags that you can later add quickly as one of your code’s parameter.
We hope you found this blog post insightful! If that was the case, please share it with your friends or colleagues!
With 🖤 from Patricia