Skip to main content

What is Feature Toggle - Best Practices, React, Unleash & Custom Software Implementation

Feature Toggle

Frederick Osburgh from Unleashed explains how feature toggles can improve the workflow of development teams and lead to quicker software delivery. Feature toggles allow for the easy activation or deactivation of specific features in a software application. Frederick Osburgh started exploring feature toggling in 2014 because he deeply cared about development proficiency and wanted to release software more frequently. Trunk-based development is a popular technique where developers mainly work on the main branch instead of using long-running feature branches. Feature toggles are used in trunk-based development to wrap new code so that it's not exposed until it's ready.

Using feature toggles allows for early testing in production, verifying new features before they are fully completed. There can be drawbacks to using feature toggles, such as technical debt and increased complexity in testing multiple toggle states. Open-source solutions like Unleash provide flexibility and allow for integration testing with pre-configured toggle states.

What is Feature Toggle - Best Practices, React, Unleash & Custom Software Implementation

Implementing Feature Toggles

Frederick demonstrates how to implement a basic feature toggle in the Free Code Camp codebase.

  • A feature toggle is an if/else statement that determines whether a certain component or functionality should be rendered based on a flag value.
  • By creating a constant flag variable (newDesignOn), we can easily toggle the new design on or off by changing its value (initially set to false).
  • Conditional rendering is used to display either the new landing page component or the old landing page component based on the flag value (newDesignOn).
  • The universal navigation header can also be conditionally rendered based on the flag value.
  • By toggling the flag, developers can easily switch between the new and old designs without modifying the codebase extensively.

Conclusion

Frederick concludes by emphasizing the benefits of feature toggles and trunk-based development.

  • Feature toggles allow for safe and frequent releases in smaller chunks, enabling faster feedback and accelerated learning.
  • While there are drawbacks to using feature toggles, such as technical debt and increased testing complexity, they can be managed

Setting the Flag to True

  • The flag in the code is flipped to true, allowing control over which component is shown.

Goal of Quick Merging and Production Deployment

  • The goal is to quickly merge changes into the master branch and deploy them into production.
  • The feature can be hidden from users until it's 100% complete.

Brittle Nature of Current Flag Implementation

  • The current flag implementation is brittle and requires conscious management.
  • Forgetting to turn off the flag can lead to unfinished features being pushed to production.

Making the Flag More Dynamic

  • Using process environment variables, the flag can be made more dynamic.
  • By setting a specific environment variable value, different configurations can be applied.

Pitfalls of Having Flags in Code

  • Risks include forgetting to turn off flags after development or accidentally pushing unfinished features.
  • External configuration allows toggling without redeploying code.

Moving Flag Configuration to an External Service

  • Using JSONbin, a cloud-based service for hosting JSON configurations, allows external control of feature toggles.
  • A new design configuration with default values is created on JSONbin.

Retrieving Configuration and Passing It Down

  • The configuration is fetched from JSONbin and used to update the state.
  • The configuration is passed down to components that need it, such as the header and landing page.

Updating Configuration Dynamically

  • An interval is set up to refetch the configuration every five seconds.
  • The latest configuration is retrieved by

Vigilance in Working with Feature Toggles

  • When working with feature toggles, it is important to be vigilant and ensure proper management.
  • The implemented functionality of feature toggles can be powerful but also limiting.
  • Certain users may need access to the feature in production, requiring careful rollout and metrics tracking.
  • Connecting multiple applications in different programming languages may require writing custom bindings or considering third-party solutions.

Considering Vendors for Feature Toggles

  • Investing hours into developing a homegrown solution may not be the most efficient approach.
  • There are paid and free alternatives available for feature toggles, such as LaunchDarkly, Split.io, GitLab, Rollout.io, etc.
  • Choosing a vendor depends on individual needs and preferences.
  • It is important to consider the development philosophy of a vendor and ensure it aligns with your own.

Importance of Vendor Selection

  • Maintaining self-developed code requires continuous effort over time.
  • Every line of code written needs to be maintained and updated as needed.
  • Looking for a vendor can provide more robust solutions that save time and effort in the long run.

Development Philosophy at Unleash

  • Unleash is an open-source product with 95% of its code freely available on GitHub.
  • Privacy is strongly emphasized, ensuring data remains within the user's ecosystem.
  • Flexibility is key to success in today's development climate. Developers like to see how things work and feel in control.

Unleash Architecture Overview

  • Unleash utilizes SDKs (Software Developer Kits) for connecting to the Unleash API.
  • The Unleash API is split into Admin API and Client API, serving different purposes.
  • The Unleash Proxy provides an added security layer and improved performance by handling server-to-server communication.

Feature Toggle Strategy Overview

  • 75% of the user base is included in the strategy.
  • The environment needs to be enabled for a strategy to be executed.
  • Setting a strategy in the project allows all feature toggles access to specific environments.
  • Strategies can be used to turn on or off an environment or a feature toggle.

Turning On Environments

  • Turning on an environment allows strategies in that environment to execute.
  • This is different from setting it in the project, which gives all feature toggles access to the environments.

Testing the Proxy

  • Calling against the proxy shows that the page toggle and feature toggle are returned based on the strategy execution percentage.

Fetching Configuration from Development Environment

  • The API token specifies which environment's configuration should be fetched by including it as part of the token.

Implementing Feature Toggles in a Real Application

  • Moving a component into a create react app project for easier development.
  • Using a feature toggle to turn on and off components within the application.

Conditional Rendering Based on Feature Toggle

  • A conditional render component renders different components based on a condition given.
  • The condition can be controlled by a feature toggle.

Creating a Feature Toggle

  • Creating a new feature toggle called "chatbots" in the Unleash instance.
  • Adding a gradual rollout strategy to the development environment.

Connecting Application to Unleash Proxy

  • Using the unleash proxy client for React to connect the application to Unleash.

Adding Remote Address Property

  • A remote address property is added with the IP address.
  • Access via the remote address strategy is demonstrated.
  • The feature is accessed when the IP address matches the value.

Focusing on Experimentation

  • Developers often want to develop different versions of a feature and try them out.
  • Experimentation and A/B testing are powerful tools to determine which version performs better.
  • Unleash allows for experimentation and integration with analytics providers.

Working with Other Services

  • Unleash focuses on providing integration points and flexibility rather than implementing built-in analytics.
  • Users can combine Unleash with their preferred analytics provider for analysis.

A/B Testing with Unleash

  • Variants are introduced in Unleash for A/B testing.
  • Variants have weight distributions that determine the percentage of users assigned to each variant.
  • Code implementation is shown, including rendering different components based on variants.

Implementing Google Analytics Integration

  • React Google Analytics package is installed and initialized.
  • User ID is passed as a parameter for tracking events in Google Analytics.
  • Events can be sent to track user interactions based on variants.

Monitoring and Cleaning Up Feature Toggles

  • Unleash provides a health dashboard to monitor feature toggles.
  • The dashboard shows toggle usage, last seen, and expiration information.
  • It helps identify toggles that can be cleaned up to reduce technical debt.

Metrics and Monitoring in Unleash

  • Metrics can be used to verify the expected behavior of gradual rollouts or strategy configurations.
  • Live updates show the percentage of users getting access to a feature

Feature Toggles - Why and How to Add to Your Software Application

Comments

Popular posts from this blog

Fake CVR Generator Denmark

What Is Danish CVR The Central Business Register (CVR) is the central register of the state with information on all Danish companies. Since 1999, the Central Business Register has been the authoritative register for current and historical basic data on all registered companies in Denmark. Data comes from the companies' own registrations on Virk Report. There is also information on associations and public authorities in the CVR. As of 2018, CVR also contains information on Greenlandic companies, associations and authorities. In CVR at Virk you can do single lookups, filtered searches, create extracts and subscriptions, and retrieve a wide range of company documents and transcripts. Generate Danish CVR For Test (Fake) Click the button below to generate the valid CVR number for Denmark. You can click multiple times to generate several numbers. These numbers can be used to Test your sofware application that uses CVR, or Testing CVR APIs that Danish Govt provide. Generate

How To Iterate Dictionary Object

Dictionary is a object that can store values in Key-Value pair. its just like a list, the only difference is: List can be iterate using index(0-n) but not the Dictionary . Generally when we try to iterate the dictionary we get below error: " Collection was modified; enumeration operation may not execute. " So How to parse a dictionary and modify its values?? To iterate dictionary we must loop through it's keys or key - value pair. Using keys

How To Append Data to HTML5 localStorage or sessionStorage?

The localStorage property allows you to access a local Storage object. localStorage is similar to sessionStorage. The only difference is that, while data stored in localStorage has no expiration time untill unless user deletes his cache, data stored in sessionStorage gets cleared when the originating window or tab get closed. These are new HTML5 objects and provide these methods to deal with it: The following snippet accesses the current domain's local Storage object and adds a data item to it using Storage.setItem() . localStorage.setItem('myFav', 'Taylor Swift'); or you can use the keyname directly as : localStorage.myFav = 'Taylor Swift'; To grab the value set in localStorage or sessionStorage, we can use localStorage.getItem("myFav"); or localStorage.myFav There's no append function for localStorage or sessionStorage objects. It's not hard to write one though.The simplest solution goes here: But we can kee