4 Feature flags best practices your team should adopt today
Feature toggle-driven development has been around for some time and with the current wave of DevOps and Continuous Deployments we’re experiencing, feature toggle patterns are gaining in popularity too.
What are feature flags in DevOps?
Feature flags, also known as feature toggles, are a common practice that enables trunk-based development while avoiding unnecessary code complexity, dead code, or a system failure. Rezvan Mahdavi-Hezaveh and colleagues from North Carolina State University released a research paper to uncover common feature toggle practices used by software practitioners.
Here are our thoughts about their findings and strategies for you to implement these best practices in your own organizations.
According to Rezvan and his team, feature toggle 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 the agile process.
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 with key information like feature toggle owner, current state, change history, and other relevant readily available to the team. The management system should also be connected to the source code to avoid manually updating information in the source code and the management system. Tools like Unleash are a great example.
Use a feature maintenance tool – Some teams opt for a maintenance tool. Whilst it functions similarly to a management system, the key difference is that the maintenance tool is not connected to the source code. Therefore, teams need to manually update and support both the maintenance tool and the source code, which can take up a lot of time. We strongly advise against this practice as you risk both platforms going out of sync that ultimately will cost you time and money to fix in the long run.
Track your changes – Keeping a log of changes to the feature toggles is crucial if and when something goes wrong. For the team to identify and learn from past mistakes, being able to look back at what really happened is crucial. The good news is Unleash supports this practice out-of-the-box.
Determine the suitability of a feature toggle – Given that adopting a feature toggle pattern can introduce more decision points in the code and increase technical debt, the development team needs to decide if a feature toggle is suitable for the work that lies ahead. Having a suitable feature toggle pattern for your team is important as it will reduce the number of feature toggles in your code and encourage your team to be more cautious when managing technical debt. At Unleash, we recommend including feature toggle practices 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. Discussing the release strategy with the product team helps the software development team understand and how the feature contributes to the overall business.
Give access to relevant teammates – Throughout this practice, everyone in the team is given permission to access, control and update the feature toggle configuration. For example, Instagram provides access to their product managers and their sales teams to grant access to users who should have access to specific features. The hosted version of Unleash can integrate with your user authentication system for easier user management within your team.
Group feature toggles – Grouping of feature toggles simplifies maintenance. In practice, how different teams groups their feature toggles differ. For instance, GoPro grouped its feature toggles into simple and higher-level categories. You can also group your feature toggles into broad categories such as release feature toggles, operational feature toggles, and experimental feature toggles. The grouping of feature toggles should be included in the grooming session of the work to be done.
Implementing these management practices doesn’t need to be difficult. In fact, most of these practices are supported by popular feature toggle tools like Unleash. These practices can help software development teams work efficiently, with feature toggle driving development.
According to Rezvan and colleagues, “initialization practices are used to make decisions about the design of the feature toggle before their creation.” These practices take place before the feature toggle is brought into the code and it is advised to include these discussions in either the release strategy or the grooming session of a new feature.
Define default values – This is to ensure 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 a naming convention – Adopting a naming convention 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 toggle according to its purpose, for instance by prefixing names with “Release”, “Ops”, or “Experimental”. This way, it’s easy for team members new and old to understand the purpose of a feature toggle. For example, if an outdated “Released” feature toggle still exists, it might be time for the team to consider removing this feature toggle from the code.
Determine the type of toggle – Note the type of toggle you will be using and be sure to group it according to the categories highlighted in the previous section.
These practices are highly dependent on the feature management tool you decide to use. The practices listed in this category include “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 as it’s an easy way to get started. Over time, this usually develops into a large project especially when initialization practices are established and other requirements are defined by your management team.
To avoid increasing the technical debt because of feature toggles, clean-up practices are established. With strategy constraints, each feature toggle is the same across your different environments or tenants, which makes clean-up easier.
Add an expiration date – As part of the release planning or grooming, the software development team is advised to set a target expiration date on the feature toggle. It’s also good practice to set up a reminder for the developer in charge. One way this can be done in Unleash is to use the Slack hook to send a reminder to the team’s channel on Slack.
Track unused toggles – Unused toggles can lead to technical debt and should be removed from the source code. Unleash makes it easy to identify feature toggles that are not connected to any application.
Limit the number of feature toggles – Rezvan’s team recommends setting a hard limit to the total number of feature toggles that are allowed at any one time. At Unleash, we don’t recommend teams to follow this mainly because it is difficult to predict how many toggles will be needed at any given time. Instead, the team should keep track of all toggles and phase out unused or outdated toggles.
Create a clean-up branch – Creating a clean-up branch reminds team members to delete toggles in the future and prevent technical debt.
Update the feature toggle configuration – Over time, your team may learn that the feature toggle served an unexpected purpose for its users. It’s a good idea to review the settings in these situations and even update them to better serve your users.
Applying best practices to real-world scenarios
For this research paper, Rezvan and his team began by looking up all available information on the internet. They combed through blogs and websites and classified these findings as internet artifacts. They found 38 internet artifacts and reached out to 36 of them where their contact information was readily available.
They received 17 responses and their findings are summarised below.
Their findings indicate that the industry is fairly mature when it comes to taking advantage of a feature management system. However, the biggest issue with the result is that the findings are based on companies that are already using and writing about feature flags and feature toggle-driven development online.
One of the biggest takeaways for us is that Clean-up practices are rarely implemented across different teams, which can lead to a build-up of technical debt over time.
Need an easier way to maintain your feature toggles? Try out Unleash Pro plan today
|GET STARTED||TRY OUR DEMO|