Jamil is the co-founder and CTO of Pattern. Jamil has been developing software for the past 20 years for organisations ranging from start-ups to some of the world's largest brands.
Feature flags: considerations and benefits
Feature flags – also called conditional features or feature toggles/switches – are a way to progressively integrate features into a software application while they’re still under development.When you wrap code with flags, it’s possible to test and finetune new features and infrastructure in production, without impacting UI or the end users.
Types of feature flags, and how they’re used
Here are three common uses for feature flags.
There are on/off switches that are used to control whether a feature is enabled or not. They are short-lived and should be removed after the feature is released. For example, you could deploy a solution to production that includes both an email and a print feature. If the feature flag is set (ON), you will email, else you will print.
This type of flag is especially useful when a feature may take longer to build than your regular production release schedule. A developer can use it to hide a feature that’s not yet completed.
These are normally used to control flow on the back end. Examples include algorithm changes, and upgrading or retiring old APIs. These are also short-lived and ought to be removed after the task is complete.
When you combine a feature flag with an experiment, led by a hypothesis, you introduce A/B testing. In the example below, you could run an experiment to determine if the email (A) or the print (B) feature will result in a higher user satisfaction. These flags should be removed once there is no need to collect test data.
Considerations when using feature flags
Here are some things to consider before introducing feature flags.
- Which users are you planning to target e.g. a specific group or all users?
- Would you like users to decide which features they want to use?
- What's the value of embracing feature flags as part of your engineering process?
- Are flags being created for features that are too small? For instance, are you using flags when fixing bugs?
- Are you disciplined in tidying up old flags? It is a developer’s responsibility to ensure old code paths are cleaned up before getting caught up with new work.
- Are teams coordinated about flags for the same feature? If different teams are creating multiple flags for the same feature, testing and releasing could become messy
Benefits of feature flags
Some advantages for developers include the ability to:
- Decouple deployment of releases and exposure of features
- Make changes and enable/disable features without redeployment
- Finetune a user's features and experience
- Enable a user to optionally select preview features
- Hide an incomplete or faulty feature.
Third party tools
When it comes to managing feature flags, there are various SaaS solutions to check out such as LaunchDarkly, Split, ProbeBeta and Optimizely.
At Pattern, we are currently recommending LaunchDarkly to our clients as a way to manage feature flags. The application uses streaming architecture to serve the flags in microseconds without making remote requests. With it, developers can deploy code and switch a feature on/off at any time; control version output and UX; as well as safely test in production for fast feedback.