This is an example of feature toggle techniques usage, so here we'll focus more on the category of Release toggles. We also wrote a blog post called Release your Software anytime. Check it out!
In order to make every commit production ready, feature toggle is one of the techniques that allow in-progress features to be checked in while still allows that codebase to be deployed to production at any time. It also means that we're separating release from deploy.
feature toggle during the release process
Step-by-step:
- Toggle OFF, start to commit/push your changes
- Release it, test it (e.g.: different environments, limit range of users)
- Then you can toggle ON
- If you notice a critical bug or some unexpected behaviour, instead of rollback or revert all the things, consider rollforward, turn the feature off and take your time to fix it.
- Once you are happy with your feature in place, remember to recycle the toggle.
The usage of feature toggle requires a lot of discipline and must be used carefully. You might end up with toggles of toggles or you could be in a situation where you just don’t know where else that toggle has being used, so you’ll never deleted it. Be mindful that you can work without it, using different techniques like Branch by Abstraction that enables you gradually make changes in a total decoupled code which also have the benefit of separation of concerns, making easy to maintain.
This repository use as an example the heart monitor, which is a quite simple way to describe a few new requirements in order to simulate how would we apply feature toggling at the application level. It's organized by branches, so the master branch will contain the final state and you can travel in time through the branches feature#1, feature#2 and so on. You can also keep track of the feature toggling journey through the commits.
You can learn with more details how cardiac monitoring works but on this example we'll over simplify what it is. Imagine that our software collects signals over time, and every minute the machine sends a signal value that our software will evaluate it and plot a chart, like on the image below:
- Given a collection of cardiac pulses as signals are available
- When the monitor evaluates certain amount of time series data
- Then it should send a message weather the heart has stopped or it's still beating
Example:
- If the line is flat (all signals remains 0), the status will indicate that the heart has stopped.
- If all signals varies with higher/lower values the status will indicate that the heart is still beating.
This code is also available on the branch feature#1.
- Given a collection of cardiac pulses as signals are available
- When the monitor evaluates certain amount of time series data
- And all signals remains the same
- Then the heart beating status should be stopped
Example:
- If the line is flat (all signals remains the same), the status will indicate that the heart has stopped.
- If all signals varies with higher/lower values the status will indicate that the heart is still beating.
This code is also available on the branch feature#2 and the pull request can also be followed through here.
The feature toggle was removed on branch recycling-feature#2 and the pull request can also be followed through here
The following features will be described here in the future.
- Describe new features
- Add new code that satisfies the new requirements using feature toggles
- Use different branches to illustrate how it would look like in a real scenario.
Install node.js. At this moment,
we're using v7.6.0
.
Install the dependencies:
$ npm install
$ npm test
- Continuous Delivery Book
- Release it Book
- Feature Toggles by Martin Fowler
- Branch by Abstraction by Martin Fowler
Pragmateam/feature-toggles is released under the MIT License.