Schedule a chat

Start Using Feature Toggles Now

May 19, 2017

In the chaotic world of software development, a smooth development workflow sometimes seems unattainable. No matter how carefully planned your development cycle is, eventually the time comes when you have your next release ready to ship, but for one reason or another, only part of that release can be deployed.

Now you’re faced with splitting up your code and someone else has already committed some new changes for the next release. This creates a mess that few developers want to deal with – you can apply a hotfix to your release branch, but then how will you go about re-integrating the code you’re just temporarily removing?

Yuck.

Feature Toggles

They can seem clumsy to use, but feature toggles are a key ingredient in fast release cycles. They’re critical if your development team practices continuous delivery. If you’re a freelancer, they give you the freedom to continue shipping code while your client mulls over when to actually show the new changes to their userbase.

Most of the criticisms against feature toggles are that they add technical debt and complicate the code, especially when they have to be sprinkled in multiple places throughout the code. But, if their inclusion is part of the typical development process, you can plan for where they’ll come into play and be able to utilize them more effectively.

Limit their usage

Knowing that you’ll be toggling a feature, you can structure your code in a more toggle-friendly way that limits where you need to guard against the status of the toggle. This may mean refactoring existing code to work with the toggle and be backwards compatible with it, but this ultimately creates fewer headaches when the time comes to permananently enable the feature.

For example, instead of wrapping a database query with an “if” statement to control whether or not a new field should be returned and wrapping another “if” statement around your display logic that displays that field, just apply it to the display logic and ignore the field in the query results.

This also helps to reduce technical debt by not having “if” statements peppered throughout your code that only apply to a single toggle.

Control feature toggles with environment variables

Hopefully your code’s configuration is managed by environment variables. If it’s not, then do that first! Controlling your feature toggles from environment variables means you can activate or deactivate the toggles without deploying a new version of your code.

Better yet, manage your environment variables with a tool like Environr or Consul. Environr provides both a CLI and an admin console to actively manage your environment’s configuration, lock configurations to prevent changes, and control access to your configurations using managed credential sets.

A better workflow

Now, when your next release needs to temporarily exclude a bit of functionality, just flip the toggle off and keep on shipping.

comments powered by Disqus