Feature Flags: The Absolute Basics

Feature Flags: The Absolute Basics

So this week I learned a little bit about feature flags - what they are, what they do, and why we would use them. If you're like me, then you like to dumb things down quite a bit. Here is a very general overview of my findings.

Feature Flags

Feature flags (also referred to as "feature toggles") allow engineers to hide and show specific features/functionality in production without deploying new code. This allows teams and companies to make changes to the product without pushing additional code. Using feature flags allows you to test out and experiment with new features while ensuring a quick-fix should there be a problem.

Sushi App Example

sebastian-bednarek-NuAamGgwymw-unsplash.jpg

Ok, if that didn't make sense, don't worry. Let's use an example to illustrate. Let's say you are building a mobile application for a new sushi restaurant. Currently, the app allows customers to view the menu and place an order. The restaurant owner comes to you and wants you to add "Loyalty-points" for customers with each purchase, so every time they place an order, they earn redeemable points at the restaurant (we're all familiar with this, right?). So you go ahead and code it up.

Once you think it's ready, you want to release it, but there are still a few question marks. Will this somehow break the already working app? Will customers even know how to track their loyalty points? What if customers complain about it? All of these questions make you hesitate to push your changes and deploy the new code.

Enter Feature Flags.

Feature flagging (yes, that's a verb) allows you to put the new features into conditionally rendered blocks. For example:

if (featureFlags['loyalty-points'] === true) {
       renderLoyaltyPoints();
}

This makes it extremely easy to toggle the new features on and off in production - all without having to deploy new code. Since the conditional is already in the code, all you need to do is toggle the featureFlags[loyaltyPoints] value.

This will minimize the risk as it is super convenient to rollback your changes and disable the toggle. Feature flagging also allows for products to have different versions in production simultaneously, allowing product owners to view which features and versions perform better or are more frequently used.

Hopefully you have a better understanding of what feature flags are and when to use them! This was just scratching the surface!