Back Arrow Icon
Go Back
Dos and Don'ts of Feature Flags
Feature Flags

Dos and Don'ts of Feature Flags

Feature flags are a way to manage functionality remotely without deploying code. You can enable or disable new feature releases with the click of a button.

Ann McArthur
Ann McArthur
December 3, 2021

Feature Flags Management and Best Practices

What Are Feature Flags?

Feature flags are a clever way to manage functionality remotely without deploying code. You can enable or disable new feature releases with the click of a button. These remote switches help you to manage the full lifecycle of a feature. Feature flags are also known as feature toggles, feature flippers, conditional features, feature switches, feature controls, and release toggles. Despite having several names, they all have the same functionality.

Whatever you call them, feature flags are there to control how your code works. For instance, if new features are released for internal testing, a feature flag can control this access. Employees with corporate emails will see the new features, while other users will not.

Feature flags are a new way to quickly change what your customers see and deliver different configurations to your users without deploying new code..

According to the 2021 DORA Report high-performing teams deploy code 46 times more frequently with a lead time from commit to deploy 2,555 times faster. They also fail less and recover from incidents 46 times faster.

How Do They Work? 

Feature flags work by wrapping code in a feature flag. From there the feature can live in the main code base but remain dormant. If an engineer, product manager, or someone on the marketing team wants to enable the code wrapped in a feature flag they can simply turn it on like a switch through a feature management platform. A feature management platform allows you to keep your flags organized and enables non-engineering members, such as product managers, of your team to turn a flag on or off and determine who will be able to view the feature flag.

With feature toggles, you can have the flag be visible to only certain users based on predetermined criteria such as making it available to only internal users or based on a user’s location, usage history, or anything else you want to specify.

What To Do

When creating a feature flag you want to ensure you’re following best practices to get the most out of your flags. This includes scoping individually, maintaining consistency, treating them like production code, making them backward compatible, and knowing when to remove them.

Scope Individually

You want to ensure your feature flags are personalized to the end-user and that it makes sense for each user to receive the feature flag they’re getting. One popular use of feature flags is to manage styling, themes, and personalized content. You can also use feature flags to manage customization and personalized themes, all from a single tool.

It's important for businesses to offer customers a consistent and personalized experience. Cross-platform feature flagging is an easy way to do this, as it allows companies to share features across platforms such as web and mobile. Using one flag to control the visibility of both those features (web and mobile) will enable fast and effective scaling. 

For example, even though the web and mobile platforms have different permutations of a feature, they can be synced through a flag. Let’s say a user has a VIP status, it's still important to synchronize the VIP experience across mobile and web so that customers get a cohesive experience.

Maintain Consistency

The process of feature flagging is pretty straightforward. When you wrap features with conditionals that decide who can see them and when you're able to steer the process at an enterprise scale. There are a few complexities, however, that come with it. You'll have to deal with managing developer workflows, complying with regulations, managing the lifecycle of your flags, and mitigating technical debt.

Your team needs to know how flags work so they can target the right users, run beta tests, and do rollouts. Now, it's easier than ever for your non-technical teammates to understand flags. By adding a user interface for flag management, you empower your team with the ability to use flags. They can create flags, coordinate them, mitigate technical debt, and manage their lifecycle to maintain consistency across your flags. 

Treat Like Production Code

If you need two code reviews before someone can merge to master, you should also need two reviews for any configuration changes to your feature flag. What's the common programming principle that says that you should avoid adding unnecessary, nested if statements? To use feature flagging responsibly, it's important to learn this principle. It's what prevents developers from adding confusing code to the system. 

Ensure that approvals are implemented for feature flag configurations. It’s all too easy to become confused when you’re not sure what goes with what or to make a change that wasn’t intended for this particular configuration. Approval flows prevent people from making mistakes and ensure that the right changes are made.

Make Them Backward Compatible

With feature flags, you have the capability to roll them back if they don’t work as expected. It’s always a best practice to use a canary test to roll out a new feature flag to only a subset of your users to see how they react to the new code. This also allows you to monitor how your code affects the rest of your system. If anything goes poorly you can use feature flags as a kill switch to quickly disable them. 

Know When to Remove Them

Flags are a powerful tool. They allow you to quickly and easily control your experiment. But once they have served their purpose, it's time to remove them from the system. Flags can be used in a number of ways: to test with internal teammates pre-launch, as a part of an experiment, or as a safety measure against buggy code. Each type of flag has its own timeline.

What Not To Do

Along with ensuring you’re using best practices to create your feature flags, it’s also important to know what not to do. 

Don’t Treat All Flags The Same

There are several different types of feature flags and it’s important to know when to use each type to maximize their effectiveness.  Release feature flags can be used to separate a feature from deployment allowing for a CI/CD cycle. Experiment flags can be used to conduct A/B tests and test out different variations of your website or app. Permission flags can be used to manage if a user can gain access to a feature. This is ideal for only having certain features available to subscribers, beta testers, or internal users.

Ops flags are ideal for when you’re releasing a new feature with unknown impacts on your system. By wrapping code in this kind of feature flag it minimizes the risk of the code negatively affecting your system. Client-side flags are used for deploying to client-side applications and grouping flags are used for toggling a group of flags on or off. Since there are so many different types of flags it’s important to use the right type based on the goal you want to achieve.

Don’t Neglect Risk Mitigation 

Feature flags are an important tool for risk mitigation. When a customer has a problem with a business’s product or service, it needs to be able to turn off that issue or feature as fast as possible. Always ensure that you can quickly and easily turn off your feature flags in case anything goes wrong.

Don’t Manually Sync Configurations

Feature flags are often implemented inconsistently, which causes business owners to experience performance degradation and improper functioning. It is important to use careful crafting and consistent implementation to avoid these issues. Two methods that are often used are managing multiple config files or in-line toggling.

Don’t Use A Critical Path Of Your Application

Your feature flagging system should not cause an outage. This means it needs to be on a separate, non-critical path. In the event of an outage, your system should function gracefully and continue to operate. If it can’t figure out which values to use, it will use the most recent cached values and defaults.

Don’t Keep Old Code

Adding more feature flags makes testing and management exponentially more difficult over time. It becomes very hard to tell which flags are necessary or obsolete. You want to ensure that you remove flags once they are no longer needed to keep your workflow clean and organized.

It's hard to keep up with flags. The process becomes arduous and time-consuming, and it's difficult to follow who created the flag, what it's meant for, and who's changed the rollout. Make sure you keep on top of your feature flags so that you’re not keeping old code

Try DevCycle Today!

The ability to manage software release cycles with feature flags is essential for the success of any organization. Implementing them also provides organizations with an additional layer of KPIs to analyze, which will improve their overall success.

DevCycle is a feature management platform that allows you to successfully manage your feature flags. With our intuitive dashboard and clear documentation, it ensures your team follows feature flag best practices. Start your 14-day free trial.

Author headshot
written By
Ann McArthur

Ann is a product specialist who helps engineers easily get started using feature flags. She resides in Toronto where you can find her at the AGO, or at home whipping up a delicious meal.

Enjoyed this read?

Stay up to date with the latest video business news, strategies, and insights sent straight to your inbox!

Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.