Feature toggle

A feature toggle (also feature switch, feature flag, feature flipper, conditional feature, etc.) is a technique in software development that attempts to provide an alternative to maintaining multiple branches in source code (known as feature branches), such that a software feature can be tested even before it is completed and ready for release. Feature toggle is used to hide, enable or disable the feature during runtime. For example, during the development process, a developer can enable the feature for testing and disable it for other users.[1] In this way, feature flags can be used to implement targeted rollouts of features to specific subsets of users, a practice known as feature gating.[2]

Continuous release and continuous deployment provide developers with rapid feedback about their coding. This requires the integration of their code changes as early as possible. Feature branches introduce a bypass to this process.[3] Feature toggles are an important technique used for the implementation of continuous delivery.

The technique allows developers to release a version of a product that has unfinished features. These unfinished features are hidden (toggled) so they do not appear in the user interface. This allows many small incremental versions of software to be delivered without the cost of constant branching and merging. Feature toggles may allow shorter software integration cycles.[4] A team working on a project can use feature toggle to speed up the process of development, that can include the incomplete code as well.

Implementation

Feature toggles are essentially variables that are used inside conditional statements. Therefore, the blocks inside these conditional statements can be toggled 'on or off' depending on the value of the feature toggles. A block of code which has been toggled 'off' is similar to it being commented out. This allows developers to control the flow of their software and bypass features that are not ready for deployment.

The main usage of feature toggles is to avoid conflict that can arise when merging changes in software at the last moment before release, although this can lead to toggle debt. Toggle debt arises due to the dead code present in software after a feature has been toggled on permanently and produces overhead. This portion of the code has to be removed carefully as to not disturb other parts of the code.

There are two main types of feature toggle. One is a release toggle, which the developer determines to either keep or remove before a product release depending on its working. The other is a business toggle, which is kept because it satisfies a different usage compared to that of the older code.

Feature toggles can be used in the following scenarios:[1]

  • Adding a new feature to an application.
  • Enhancing an existing feature in an application.
  • Hiding or disabling a feature.
  • Extending an interface.

Feature toggles can be stored as:[5]

  • Row entries in a database.
  • A property in a configuration file.
  • An entry in an external feature flag service.

Feature groups

Feature groups consist of feature toggles that work together. This allows the developer to easily manage a set of related toggles.[6]

Canary release

Another benefit of feature flags is canary launches. A canary release (or canary launch or canary deployment) allows developers to have features incrementally tested by a small set of users. If a feature's performance is not satisfactory, then it can be rolled back without any adverse effects.[7]

Martin Fowler states that a feature toggle "should be your last choice when you're dealing with putting features into production". Instead, it is best to break the feature into smaller parts that each can be implemented and safely introduced into the released product without causing other problems.[8]

Feature-toggling is used by many large websites including Flickr,[9] Disqus,[10] Etsy,[11] reddit,[12] Gmail[13] and Netflix, [14] as well as software such as Google Chrome Canary.

gollark: I avoid this by running LineageOS on my device.
gollark: LB?
gollark: I had a Wileyfox Swift with that (dead because of the USB port thing), but they're no longer sold and I don't think replacement parts exist either.
gollark: Hmm, I think I actually know someone with one of those still.
gollark: Does anyone know of phones with removable batteries (and good availability of said batteries), no notch, an LCD (not OLED) screen, a μSD card slot, decent battery life, and some custom ROM support, which is still produced or fairly available used? Do any even exist now?!

See also

References

  1. "ALM Rangers - Software Development with Feature Toggles". msdn.microsoft.com.
  2. "Feature Flags (aka Feature Toggles)". optimizely.com. Retrieved 14 July 2020.
  3. "Feature Flags for Mobile Apps - Apptimize". apptimize.com. Archived from the original on 18 September 2016. Retrieved 9 January 2017.
  4. Programming JavaScript Applications. Archived from the original on 2016-09-15. Retrieved 2016-09-14.
  5. Echagüe, Pato (2014). Managing Feature Flags. O'Reilly Media. ISBN 9781492028598 via https://www.oreilly.com/library/view/managing-feature-flags/9781492028598.
  6. Elliot, Eric (2018). Programming JavaScript Applications. O'Reilly Media.
  7. "Canary launches – how and why to canary release". launchdarkly.com. 7 April 2015. Retrieved 9 January 2017.
  8. Martin Fowler 29 October 2010 (2010-10-29). "FeatureToggle". Martinfowler.com. Retrieved 2013-09-27.
  9. Harmes, Ross. "Flipping Out - code.flickr.com". flickr.net. Retrieved 9 January 2017.
  10. dcramer (July 9, 2010). "Partial Deployment with Feature Switches". Archived from the original on 2013-11-05. Retrieved 2013-10-10.
  11. "How does Etsy manage development and operations?". codeascraft.com. 4 February 2011. Retrieved 9 January 2017.
  12. "reddit/reddit". github.com. Retrieved 9 January 2017.
  13. "Developing Gmail's new look". googleblog.com. Retrieved 9 January 2017.
  14. "Preparing the Netflix API for Deployment". netflix.com. Retrieved 9 January 2017.
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.