Do you have a variable flag which depending of the configuration the flag will enable/disable (toggle) to execute some lines of code of a feature.? are you tired of this approach?
This patterns was known as “Feature Toggle” which is a set of patterns which can help a team to deliver new functionality to users rapidly but safely.
“Feature Toggling” could be done with t just a variable flag but there are other better way to do it but of course it will require more time to implement it.
Working with toggle feature it will help in:
- Adopt new technologies as part of feature toggles
- Clean Code (if don’t use just simple variable flags)
- Reduce Risk branch merges issues “feature branch”
- other more things!

Image source from this great “Feature toggling” article
“Feature Toggling” could be used when
your software need to use a feature that break backward compatibility and is only available in the latest version of a library . Instead to break the backward compatibility or don’t get the latest version of the library it could be modify the code to call that new feature only if the software has the latest version otherwise it won’t use this feature and it will execute other code. With this approach it will adopted fastest the latest libraries version instead to wait years to be possible to update you code.
From a software architecture point of view which solution and patterns do you use for the “Feature Toggling” ?

I think one possible solution it could be create some artefacts which will inject the desired code to be executed with a dependency injection library instead to have a simple flag with more code in the same location.
I think the correct approach is to try to have those new toggle feature code in a separated location but once release is complete toggles need to be removed.
Instead to reinvent the wheel bear in mind there are some existent library help with this and here below we have some example links
There could be some disadvantages like:
- flags make the code more fragile if won’t be well designed
- harder to test if it wasn’t well documented or created test,
- harder to maintain if it wasn’t properly designed and there no test
- What else?
Here we have a list of great articles about toggle feature:
- Feature Toggles (aka Feature Flags)
- Effective Patterns for Feature Flags
- Continuous Delivery using feature toggle
- Feature Flags
- Implementing Feature Toggles in .NET
- Feature toggling using ASP.NET
Don’t try to don’t reinvent the wheel and use an existent C# libraries:
- LaunchDarkly .NET Feature Flag SDK –
- .NET Feature Flags – CodePlex
- NFeature – Ben Aston
- FeatureSwitcher – Max Malook
- nToggle – Steve Moyer
- Toggler – Manoj
- FeatureToggle – jason-roberts
- FeatureSwitcher –mexx
There are also Web development toggle feature libraries like:
- Angular
- React
- Typescript
Feel free to share with me how do you archive this or to discuss about this topic
Do you use feature toggle to provide a mechanism for pending features that take longer than a single release cycle?https://t.co/71T1vCNWPa
— Jesús Estévez (@jecaestevez) March 10, 2018

Tweets related with this topic:
You could use DI and change behaviours by injecting another implementation in config file 😉
— MarcoTako (@marcotako) March 10, 2018
Indeed, Feature Toggles used as configuration settings to tailor your product to specific customer needs. Moreover, can be done also automatically if detected, based on feature detection. A là modernizr: https://t.co/4dWVAOkzpK
— Pedro J. Molina (@pmolinam) March 10, 2018
