Using feature flags in Software Development
Flagging of features? The first time I heard of feature flag I was a bit confused. What exactly does that mean? In the world of software development the term 'flag' is used to define a value which is used to notify downstream systems of a new change. Usually flags are a boolean value but as with many things in software development, you can use enum types as well. A flag is useful to determine the control flow of a journey flow, for example you may use a flag to gate/hide certain functionality. This can be used across front-end and back-end development. In the front-end development you may want to hide certain UI elements. In the back-end development you may want to hide certain logic from the control flow. In both cases this can be as simple as adding a boolean value.
My Experience Using Feature Flags
I used a feature flag in my most recent project (https://house-buyers-toolkit.netlify.app/), which I talked about in my previous post. It is fairly easy to do in React, you can use the createContext that lets the components provide values that the components that can read. This gives you a central location for you to toggle the feature flag on or off. In this file I chose to use boolean type for the feature flags because I was mainly using it for showing/hiding components and any associated sub components.
import { createContext } from "react";
export const FeatureFlagsContext = createContext({
renderNavigationComponent: true, //Example feature flag for rendering
the navigation
renderAboutComponent: false,
renderContactComponent: true,
otherFeature: true, // Example for another feature flag
})
It was very satisfying to show and hide components from toggling a flag on and off.
Feature flags are very useful for software development:
- Hiding UI Component fields - for example if you need to hide a new feature, or for example there is an issue with delivery provider so you need to temporarily hide your delivery page, you can implement a feature flag.
- Hiding Business Logic in Back-end flows - for example if you need to push a feature into production but want to hide it from your user base. You can gate the logic with a feature flag.
- Circuit-breaking (Back-end and Front-end)- for example if there is a breaking change or cascading failure due to another component, you can quickly adjust the control flow by toggling a feature flag to maintain a good customer experience and give your team the ability to work on the component in the background, as opposed to taking your entire application offline for debugging.
The other great thing about Feature Flags, is the ability to control the flags programatically. For example methods can be set to automatically update the feature flags. For example if there is an unexpected level of traffic you can implement a circuit breaker with a feature flag to gate certain functionality, to preserve your server resources.
Use Case: Feature Flags with Personalization
The other big use case for Feature Flags is adding personalization. Over the last few posts, I have spoken a bit around personalisation with respect to Artificial Intelligence and the Personalized Customer Experience.
However, as an product development team personalization is going to be even more important in the years to come, because users are demanding a unique software experience, they want tailored suggestion, personalised emails not generic templates with some parameters. Customers want to feel that the software they are using is truly catered for their needs.
Feature Flags can be a very helpful way of doing that. As mentioned above one of the use cases for Feature Flags is to show and hide components, as shown with my React Context excerpt above.
However what if you programatically control what components to show based on a users age, or what if your backend can provide an aggression of attributes about the specific customer provide those to the front-end. For example may be a back-end service can aggregate the key clothing items purchased over a specific period, and return a set of suggested products to display on the front-end, or another use case could be a customer that is provided with the same delivery time slot based on the previous order with a specific delivery partner.
All of these cases can be enhanced upon with using feature flags.
Conclusion
Overall, I hope that has given some insights into how feature flags can be useful in software development, with delaying release management, handling issues or errors in productions, to providing a truly personalised experience.