Feature flag best practices your team should adopt today 
Feature toggles, also known as feature flags, are a common practice that enable trunk-based development. They also help avoid unnecessary code complexity, dead code, or system failures.
Feature flag-driven development has been around for some time. With the ongoing trends towards DevOps and continuous deployments, feature flag patterns are getting pretty popular, too.
Reviewing feature-flags in DevOps
Rezvan Mahdavi-Hezaveh and colleagues from North Carolina State University released a research paper to uncover common feature-flag practices used by software practitioners.
According to Rezvan and his team, feature flag best practices can be broken down into four main practices:
- Management practices
- Initialization practices
- Implementation practices
- Clean-up practices
In the illustration, the four practices are added to a blueprint of a typical Agile process.
Follows are some of our thoughts about their findings. We also include some strategies for implementing these best practices into your own organization.
Management practices examine how teams make and execute decisions about using feature toggles in development.
Use a feature management system
Most teams use a centralized system to control various feature toggles within the company. The management system should have a centralized dashboard. Ideally the dashboard would display key information like “feature flag owner”, “current state”, “change history”, and other information your team would find relevant.
The management system should also connect to the source code so you don’t have to manually update information. Solutions like Unleash are a great example of a feature management solution.
Use a feature maintenance tool
Some teams opt for a maintenance tool. While it functions similarly to a management system, the key difference is that the maintenance tool does not connect direclty to the source code.
This can force your team to manually update and support both the maintenance tool and the source code, which can take up a lot of time. In addition, maintenance tools carry a significant risk of both platforms going out of sync. Bringing the platforms back in sync can cost a lot of time and money to fix.
Track changes to your feature flags
Keeping a log of changes to the feature toggles is crucial. You need to know if and when something goes wrong.
For the team to identify and learn from past mistakes, you need an accurate log of what really happened. Good news: Unleash supports this practice right out of the box.
Determine the suitability of a feature flag
Adopting a feature flag pattern can introduce more decision points in the code and increase technical debt. Your development team needs to decide if a feature flag is suitable for the work that lies ahead.
It’s important that your team has a suitable feature-flag pattern, as it can reduce the number of feature toggles in your code. Bonus: Feature flag patterns can encourage your team to be more cautious when managing technical debt.
At Unleash we recommend including feature flag patterns as part of the process of planning a new feature. For larger teams, we suggest including feature toggles as part of the discussion between the product manager and the software development team.
When you discuss your release strategy with your product team, you also bring a layer of transparency. This helps the software development team better understand how the feature contributes to the overall business.
Give feature flag access to your teammates that need it
Ideally you should give all invested team members some level of permission to access, control and update the feature flag configuration. For example, Instagram provides permissions to both their product managers and their sales teams to control user-access to specific features.
To make it easier, the hosted version of Unleash can integrate with your user authentication system. The goal is to make sure your team user management experience is smooth and simple.
Group feature flags
You can simplify feature flag maintenance through grouping. In practice, how different teams groups their feature toggles differ.
You could, for example, group feature toggles into simple and higher-level categories. You can also group your features into broad categories such as release features, operational features, and experimental features.
Reviewing how you group your features should be a key part of your regular workflow.
Implementing feature-flag management practices doesn’t need to be difficult. In fact, most of these practices are supported by popular feature flag management solutions like Unleash. These practices can help software your developer team work efficiently and let your feature toggles drive development.
Read more: Learn how feature toggles can bring more value to your business
According to Rezvan and colleagues, “initialization practices are used to make decisions about the design of the feature toggle before their creation.”
The initialization practices should take place before the feature flag is brought into the code. We think it’s a good idea to include these discussions in either the release strategy or the planning session of a new feature.
Some key talking points:
Define default values – This helps make sure that the behavior in the code is as expected. With Unleash, the default value is always set to “off” unless another value is defined.
Use naming conventions – Adopting a naming conventions is generally good practice when it comes to software development, and it is true for feature toggles as well.
A good rule of thumb is to name the feature flag according to its purpose. You could, for example, include a prefix like “Release-”, “Ops-”, or “Experimental-“.
This makes it easier for team members understand the purpose of a feature flag, no matter how long they’ve been in your team. Following the previous example, if an outdated “Released-” feature flag still exists, it might be time for the team to consider removing this feature flag from the code.
Determine the type of flag – Note the type of flag you will be using and be sure to group it according to the categories highlighted in the previous section. You can read more on feature flag best practices here.
Everything we’ve discussed so far can be highly dependent on the feature management tool you decide to use. Feature-flag implementation practices are no different, and include factors like “Type of assigned values”, “Ways to access values” and “Store type.”
From our experience, we’ve noticed that software development teams tend to start by hard coding feature toggles into their code. It’s an easy way to get started, and, over time, this usually develops into a large project.
This is especially true when initialization practices and other requirements are defined by your management team.
Without smart implementation, feature toggles can increase technical debt. This is why you should take on regular cleanup practices.
Unleash’s solution includes strategy constraints. These constraints are great for making sure your feature toggles are the same across your different environments or tenants. Your cleanup becomes that much easier.
Add an expiration date – As part of your release plan, it’s smart to set a target expiration date on each feature flag. It’s also a good practice to set up a reminder for the developer in charge.
In Unleash, you can use our Slack hook to send a reminder to the team’s channel on Slack.
Track unused feature flags – Unused feature toggles can add up to a lot of technical debt over time, and should be removed from the source code on a regular basis. You’ll find that Unleash makes it easy to identify feature toggles that are not connected to any application.
Limit the number of feature flags – Rezvan’s team recommends setting a hard limit to the total number of feature flags that are allowed at any one time.
In this case we don’t actually recommend teams to follow Rezvan’s advice. This is mostly because it can be difficult to predict how many toggles will be needed at any given time.
Instead, your team should keep track of all flags, and, again, phase out any that are unused or outdated.
Create a clean-up branch – Creating a clean-up branch reminds team members to delete flags in the future and prevent technical debt.
Update the feature flag configuration – Over time, your team may learn that a feature flag served an unexpected purpose for its users. It’s a good idea to review the settings in these situations and even update them to meet the needs and desires of your users.
Applying best practices to real-world scenarios
Before we go, let’s return to Rezvan’s original research.
For their research paper, Rezvan and his team combed through blogs and websites, then classified these findings as internet artifacts. In total, they found 38 internet artifacts, and were able to get in touch with 17 of them.
Each of the 17 artifacts received a survey. Here are their responses.
Their findings indicate that the industry is fairly mature when it comes to taking advantage of feature management systems.
That said, the biggest issue with the result is that the findings are based on companies that are already using and writing about feature toggle-driven development online.
Overall, one of our biggest takeaways is that clean-up practices are rarely implemented across different teams. Over time, this can lead to a pretty huge build-up of technical debt.
Need an easier way to maintain your feature flags? Try out Unleash today.
|START FREE||PLAY WITH DEMO|