When using continuous integration branching is considered a no no. This being the case you need feature toggles. The concept is quite simple, but how do you actually use them in code? I've come across this tricky problem at work and with the help of some colleagues came up with a very simple approach. But what if you don't want to roll out your own? What's available? Here is a brief overview of three tools available based on a quick Google search.
NFeature
NuGet package - Code - Example
Features
- Custom feature states. E.g. Previewable will only be seen by users who meet certain criteria. Established means the feature toggle cannot be removed
- Custom feature availability functions. E.g. Make feature available on site load or presence of a cookie
- Feature dependencies
- Feature availability dates
- Feature specific settings can be defined using JSON
Configuration
- Toggles defined in enum and web.config
- Availability checking methods set up
- Manifest set up. The manifest service is used to check the state of existing toggles. This service must be injected into any class where toggles are required
Advantages
- Large amount of control over when and how to flip toggles
- Available via NuGet
Disadvantages
- More configuration required that other feature toggling tools I looked at
- No view examples provided. I'm unsure how NFeature would be used to add a toggle to a view
- Potentially tricky to implement. This is probably just my fault, but I found it difficult to see how NFeature could be easily integrated with our existing code base
- Manifest service must be injected into any class where toggles are required. On a big project this could affect a large number of classes
FeatureToggle
NuGet package - Code - Example
Features
- Custom feature toggle types including always on, always off, enabled and after date
- Supports XAML
- Toggles can be loaded from the database
- WPF and Windows phone 7 support
- Custom feature toggle implementations can be created by implementing IFeatureToggle
Configuration
- Toggles defined in appSettings
- Each toggle must also be created as a new class which extends an existing feature toggle class. E.g. EnabledOnDatesFeatureToggle
Advantages
- Supports multiple platforms
- Multiple toggle types
- No service class required so no IoC set up required
- Incredibly simple to set up and use
- Toggle type and provider are extensible
- Available on NuGet
Disadvantages
- You have to create a class for each toggle
- Toggles can't be used statically and must be instantiated as far as I could tell. This isn't a major issue to be fair, I'm just not a fan
- Difficult to use across large solution. E.g. I would like to be able to define my toggles in a common project and use them in several web projects
- Breaks existing unit tests. I'm unsure how to mock toggles when using FeatureToggle
FeatureSwitcher
NuGet package - Code - Example
Features
- Can check features statically or with instance
- Fluent interface
- Multi tenancy support
- Custom behaviours (to be honest after reading the documentation I was unsure what custom behaviours were)
Configuration
- Toggles defined in custom configSection
- Create a class which implements IFeature
Advantages
- Can check features statically or with instance
- Fluent interface looks very flexible and powerful
- Multi tenancy support
Disadvantages
- Personally, I found the documentation quite confusing. After reading the readme I still had a lot of unanswered questions about how to use the toggles and wasn't sure about how to configure FeatureSwitcher in my own projects