What are feature flags?

When we develop software, and build functionalities that take a long time to implement, we don't do it in a separate branch and merge it at the end with the rest of the code. Instead, we build it little by little and the code is always alongside the main codebase. But of course, this code is unfinished, so how do we avoid breaking the application?

 



1 - What are feature flags?

Feature flags (also known as feature toggles) are a technique that allows us to select functionality at runtime without having to redeploy the code.

Of course, both parts of the code must be deployed with the application. What we do with this functionality is choose which part of the code to execute.

 

For example, let's say we have a system that sends information via FTP to another part of our system. The receiving system has implemented a new functionality to receive information via HTTP (REST API) instead of FTP.

In the application that sends the information, we have both workflows. If we have the feature enabled, it will use one; if we have the feature disabled, it will use the old one.

feature flags description

Note: keep in mind that feature flags allow us to enable two behaviors at once, which means we have two workflows to maintain. In the long run, this results in higher complexity if we leave them enabled and forget about them.

 

1.1 What is not a feature flag?

Configuration. Some companies use feature flags to configure how certain clients work. Flags are not intended for this functionality; for that, you have configurations.



2 - Feature flag use cases

There are quite a few use cases, but the most common ones are the following:

 

2.1 - Continuous development 

Thanks to how feature flags work, we can continuously develop features because, until that functionality is finished, it will not be used, since the feature flag will remain off.

 

This allows us to develop features in chunks without worrying about creating a branch for that feature and then merging, with all that involves and possible conflicts.

 

2.2 - Migrations

Suppose you are developing an application and you are going to migrate from one use case to another , for example, from sending elements over FTP to HTTP. You have both workflows in the system, and you enable the feature flag. If something goes wrong, you simply disable it, and everything works as before.

 

Meanwhile, the team focuses on fixing the issue.

 

2.3 - A/B Tests

This is similar to the previous case, but this time we have both active for a while. We monitor their behavior and compare them to decide which option is best.

The same applies to the front end and conversion, for example, the A/B testing YouTube uses with thumbnails.



3 - Benefits of feature flags

As you may have noticed in the previous section, the great benefit of feature flags is that they allow us to change code and deploy it to production without worrying too much about our change being perfect. If it fails, you simply need to press a button to revert to the previous workflow or limit functionality (in the case of A/B testing).

 

Some feature flag services allow you to add information to the request, such as the client, which means that certain functionalities work only for a specific client during a specified time. For example, a particular feature flag is enabled only for one client for two weeks; if it goes well, you enable it for everyone, and once the trial period ends, you remove the feature flag to keep only the new workflow in your code.



4 - Implementing feature flags

When it comes to implementing feature toggles, it's very simple. All you need in code is to abstract the logic to call the corresponding service. This service could be a simple database.

 

But I personally recommend using a third-party service.

Whether it's LaunchDarkly, ConfigCat or Unleash (which I recommend, because its CEO and co-founder was once my manager, so a little bit of promotion isn't bad), the most important thing if you choose a third-party service is that it has an SDK for the programming language you use.

 

This post was translated from Spanish. You can see the original one here.
If there is any problem you can add a comment bellow or contact me in the website's contact form

Uso del bloqueador de anuncios adblock

Hola!

Primero de todo bienvenido a la web de NetMentor donde podrás aprender programación en C# y .NET desde un nivel de principiante hasta más avanzado.


Yo entiendo que utilices un bloqueador de anuncios como AdBlock, Ublock o el propio navegador Brave. Pero te tengo que pedir por favor que desactives el bloqueador para esta web.


Intento personalmente no poner mucha publicidad, la justa para pagar el servidor y por supuesto que no sea intrusiva; Si pese a ello piensas que es intrusiva siempre me puedes escribir por privado o por Twitter a @NetMentorTW.


Si ya lo has desactivado, por favor recarga la página.


Un saludo y muchas gracias por tu colaboración

© copyright 2025 NetMentor | Todos los derechos reservados | RSS Feed

Buy me a coffee Invitame a un café