There is no consensus on the designation and the list of synonymous terms is very long: Feature Flag, Feature Switch, Conditional Feature, Feature flipper, Feature Bits, Gatekeepers….

The principle

When a new version of the software is delivered to an environment, all new features are made available immediately. Rather, the Feature Toggle * design template is intended to provide a feature switch that turns some code on or off without requiring redeployment or restarting the application.

Possible uses

 

This feature can have many uses. The following cases are an example and do not represent the completeness of the situations.

 

CASE 1 – Different needs in different environments

 

Making regular, frequent, and small deliveries are one of the conditions to be guaranteed for the agility of a project  (Continuous Delivery). The challenge is to maintain a short development cycle to limit the risks of the high rate of change. However, if this strategy proves to be an asset in a test environment, where the validation of small software bricks reduces the duration of the testing phase, it can be difficult to achieve in a production environment. Indeed, a functionality can represent several iterations of developments and it would be incongruous to make it available to the user in an incomplete way. The feature toggles system makes it possible to deliver parts of features in a disabled mode without affecting the stability of the code. Activation can be done after a few weeks, once all the necessary code has been delivered.

 

CASE 2 – Incident following a delivery

 

When a malfunction is encountered in production by a user following a recent delivery, it will be possible to deactivate the functionality to reduce software instability while awaiting resolution.

 

CASE 3 – Dependencies between teams

 

It is not uncommon for several teams to work in parallel on different needs and within their own deadlines while having one or more applications in common. For example, the interface can be the same for all teams. When the time has come for a team to deliver its work, it is embarrassed by developments still in progress or by validation of other teams on the shared application. If each team has toggles in place, delivery will be possible on the condition that each functionality not yet completed is deactivated.

 

CASE 4 – Comparative tests

 

There is a category of Feature toggles that are activated by the user. The activation condition can be determined by a permissions profile or by membership in a sample. Instead of multiple environments, only one is needed to compare results between different groups of users and validate an approach.

 

 

OTHER CASES – Activation of features can also…

 

  •     concern the configuration of an operational system already in service in order to determine the best parameters (short term) or to maintain a strategic service to the detriment of another by degrading performance to its benefit (long term)
  •     be required to remain in the long term in the case of the need for customization of functionalities by the user (for example a “premium user” mode)

 

According to Martin Fowler 1 – his blog, there are two areas of qualification for a toggle feature, its dynamism (changes during deployment / hot / per request) and its longevity (number of days/months/years). This classification should guide the choice of implementation.

 

A quick overview with FF4J

 

FF4J  (Feature Flipping for Java) is an apache 2 free license framework.

Once the necessary dependencies have been added (ff4j-core, JUnit, ff4j-web) and the configuration has been configured, you will need to create a service providing an instance of the FF4J class.

 

Step 1. Create a toggle feature

 

This consists of inserting a new entry in a feature store (the storage system) specifying the identifier of the toggle, its description, its activation status, its membership group, the user roles, or the associated policies. The data storage system offer is wide: memory, relational databases, or no-SQL.

 

Step 2. Use the toggle feature in the code

 

The identifier chosen in step 1 will verify the activation status.

If (ff4j.check(“id.du.toggle”)) {

         doBehiavorA()

}  else {

         doBehiavorB()

}

above: if the toggle is activated then behavior A is played otherwise behavior B works.

 

Step 3. Deploy the code to an environment

 

Step 4. Control activation via the administration console

 

Limits:

 

     This mechanism makes the code more complex: two cases of behavior are implemented at the same time, therefore twice as much code. It is therefore advisable to think about the right strategic locations in the code and to limit the number of appeals. In the same vein, the total number of features covered must be kept low to remain maintainable.

 

     Fortunately, this risk is reduced in most uses since they meet a temporary need. However, this temporary situation will induce an additional operation of cleaning the code, once the functionality is permanently activated.

 

     There are also a few cases where securing a toggle is not an option. In particular, I have already encountered the case during a major structural change in the model being planned.

 

     There is controversy. Indeed, version management tools (such as Git) provide invaluable help in resolving certain issues (eg CAS 3). If the very common practice of Feature Branching (separation of functionalities into branches) is considered unsuitable in the face of the challenge of continuous integration and delivery for some 1 – martin fowler blog, it remains a possible answer when well executed for others. other 2 – James McKay blog. These approaches can also be used side by side.

 

     Finally, this approach goes hand in hand and will make sense in a context where the automation of tests and deployments is already in place.

Some implementations

Flagger (Android), angular-feature-flags (Angular), rollout.io (javascript), Toggle (Java), within the Spring framework (Java) …

Author Bio:

This is David’s work as a digital content marketer at folio3 turn on-off developer options in Android. Besides that, I love to read and love to play video games and I like to ride a sports bike too.

 

Leave a Reply

Your email address will not be published. Required fields are marked *