Feature Toggle

What is a Feature Toggle?

A Feature Toggle is a technique which lets us to turn on/off a feature of an application via a configuration file. Sometimes it is also called a Feature Flag.

Why do we need a Feature Toggle?

There are a few key reasons we think it is a good idea to have feature toggles in your application:

  • More modular app structure

  • Easier debugging

  • Control over which features are released in which environment

More detailed explanation is provided below.

In long term projects where releases go in parallel with the development it is very important to keep code versions separate. It is quite common that different features are planned for different releases. It is very convenient to have feature toggles. They can isolate the feature until the appropriate time comes.

When the codebase size is growing it is becoming more difficult to maintain the code. When it is necessary to debug issues, sometimes it is very difficult to pinpoint the problem because of the interconnection of functionalities. Setting up a centralized config file for different environments to toggle application's features makes it much easier to find a problem.

When epics, stories, tasks are created the existence of a feature toggle concept enforces to follow a certain approach in design, architecture and code. It enforces a more modular approach of thinking. Features of the application have to be designed with a thought that they should be mutually independent to a possible extend. Thus, there are no unnecessary interconnections between features are being made. So, if later there is a production issue that has to be resolved the problematic feature can be just turned off.The issue can be resolved on the side while the rest of the app is functioning and available.

Feature Toggle in Codesoju app

We introduced a local feauture toggle config file for our yeoman generators to include features that require an individual setup.

The purpose of the generators is to give a developer a foundation that one can build on. It is a generic tool that offers a scaffolding for the most common features across the applications. For example, in Codesoju generators we currently we identified two features that are very common and we wanted to suggest solutions for: authentication and content management system. For authentication we recommend Auth0 and for CMS - Contentful. Please follow the links to read related articles.

These both solutions require credentials and might require some custom configurations. As well as each application might have unique needs. Therefore, we can't provide those features out-of-the box. But we do have a scaffold and we have some guidance as a part of a generator content or as helper videos.

Below you can see a FeatureToggle service which comes with the generator. It is an Angular factory. It has current feature toggles as well as it broadcasts the state of the feature toggles when the app is initialized.

You see the examples of auth and cms_content features present. They both initially are switched off. Setting them to true suppose to trigger the implementation of those features. Once the configuration instructions are followed and they are connected to the user accounts with valid credentials those features should be available to the user.

Last updated