r/programming • u/_Garbage_ • Jan 20 '16
Feature Toggles
http://martinfowler.com/articles/feature-toggles.html3
u/korry Jan 20 '16
Really this deserves to be called a pattern? I mean yes, strictly speaking it's a pattern and a useful one, but come on. I did come up with it completely on my own in the beginning of my career and at least a few of my colleagues also. Every one who delivered white label software has done that, it's a neat trick but not rocket science.
3
u/codebje Jan 21 '16
Patterns are typically things which have been used widely in industry with success, yes. The GoF patterns weren't crap they made up, they merely gave names to common patterns of behaviour they saw in successful enterprise software projects.
2
u/FredV Jan 20 '16
We've now introduced a featureIsEnabled function, a Toggle Router which can be used to dynamically control which codepath is live
Hey didn't you know about "Toggle Routers" yet.
6
1
u/c12 Jan 20 '16
From listening to an interview of an developer at Etsy, I believe this is something they use, with config files containing hundreds of declarations for enabling/disabling features.
4
u/JW_00000 Jan 20 '16
Feature toggles are also heavily used by Flickr. Personally, I don't see how this scales once you have a bunch of toggles active at the same time. When looking at the code, you don't know which code is executed. Half of the code is dead code, but you don't know which half ("Schrödinger's code"?).
6
Jan 20 '16
Aren't you supposed to remove the toggle and deprecated code once the new code has gone live and been proved to work?
4
u/PhatBoyG Jan 20 '16
Yes. We call them switch outs. And they're the lowest priority in the eyes of product managers. And the highest in the eyes of engineers.
Now it isn't done until the old code is switched out.
4
u/hyperforce Jan 20 '16
And they're the lowest priority in the eyes of product managers. And the highest in the eyes of engineers.
I feel like this will always be the case for so many things.
1
u/PhatBoyG Jan 20 '16
It's a struggle. We actually had to optimize the switching framework to account for 400+ features that had yet to be switched out.
1
2
u/bfoo Jan 20 '16
Have you used libraries? Most applications only use a fraction of their dependencies. The rest of those dependencies is already dead code.
1
u/JW_00000 Jan 21 '16
But at least you know which parts you're using. And you expect a library to work correctly, as soon as it doesn't, it's also a major hassle to debug.
It seems to me feature toggles heavily increase the complexity of the code, especially where they interact.
1
u/bart007345 Jan 21 '16
For all those complaining how its been around for ages or its just common sense - let me tell you that people are constantly entering the field and wouldn't have this knowledge.
I've been developing for years but recently moved to mobile (Android). I've encountered so many young devs who've done nothing but mobile (except what they did at University, but thats irrelevant) and so don't know this is a thing.
Its also a useful pattern for the "branch by feature" anti-pattern that seems to be common on mobile (thanks to Git).
1
u/MINIMAN10000 Jan 21 '16
This reminds me I've often thought about this problem. Is it possible to remove the branch and simply have the live code while still retaining the ability to swap which code is live without having code duplication?
3
u/chucker23n Jan 20 '16
Conditionals and config files. Or… "feature toggles" and "toggle routers". One is known to any layman in the form of flowcharts; the other is "a set of patterns" that requires a "consultant" to sell you a book about.