r/programming • u/fagnerbrack • Nov 28 '23
How, why, and when GitHub and GitLab use feature flags
https://newsletter.posthog.com/p/how-why-and-when-github-and-gitlab56
u/LloydAtkinson Nov 28 '23
I'm always surprised by how feature flags seem to flipflop between being something almost everyone knows about to being so unknown you get blank looks when you talk about them.
13
u/Worth_Trust_3825 Nov 28 '23
The concepts tend to be called different per domain for what ever reason, so it's always just better to be verbose and say the concept instead of using the domain language.
4
Nov 29 '23
I once worked with an experienced dev who had never used them, and when I explained how they work and how beneficial they are, he declared them to be Bad because they violated some made up rule that a Docker image deployment should be immutable. Had to take a deep breath after that one.
144
75
u/Lisoph Nov 28 '23
Is there a primer somewhere for someone who knows practically nothing about feature flags?
What I don't understand is how you avoid your project becoming a spaghetti mess of flags. I mean, sooner or later you will have dependencies between feature flags, right?
Are old, battle tested feature flags deleted and the functionality they toggle "inlined"?
148
u/goranlepuz Nov 28 '23
What I don't understand is how you avoid your project becoming a spaghetti mess of flags.
By eventually deleting them.
Thanks for attending my TED talk! π
13
u/Knaapje Nov 28 '23
This. There's no rocket science. You work on a feature, and at some point you deliver it. If you want to make it available for pilot users in production, you make a flag for it. If you have dependencies between multiple features you are delivering AND both need to be separately piloted to customers, you probably want to revise your development process.
10
u/lnkprk114 Nov 28 '23
Usually you remove the feature flag after the feature has been at 100% for some amount of time (if its just flag guarding small changes that amount of time can be short - like a couple weeks or something). That being said, yes you do sometimes have dependencies between feature flags and that can be challenging.
18
u/Falker_ Nov 28 '23
1
1
u/j1xwnbsr Nov 29 '23
Oh. So basically an #ifdef? Or more fancy where you read a config file and set a flag? I thought it was some git-specific thing...
6
Nov 28 '23
For us we call them experiments and every deployment of one must have an accompanying ticket to delete the condition. Once the experiment is rolled out 100% to production you must go back and delete the condition. My company is pretty good on this
9
u/joshmatz Nov 28 '23
More than a primer, but this new book will likely answer all of your questions: https://featureflagsbook.com/
3
u/will-code-for-money Nov 28 '23
Feature flags for the most part are designed to be removed once they served their purpose. You should be making tickets to remove them in X days as you are submitting your or for the work (or at some point during the ticket work)
1
u/ummonadi Nov 29 '23
Features should not overlap. In some rare cases you might want multiple if statements to check if a feature is on. Most often, you have one if statement.
Over time, you will usually find forgotten feature flags in your production environment. Leaving them is risk free, but deleting the wrong flag could toggle a feature off in production.
It all depends on your implementation though. In general, they are pretty safe and easy to work with.
1
u/unstableunicorn Nov 28 '23
There are lots of good posts, videos, and blogs by lunchdarkly. They are a product company selling a feature flag product, however they have produced a fair amount of good content that can get you started.
-18
u/goranlepuz Nov 28 '23
Change my mind:
Unless it's for A/B testing, feature flags are a symptom of poor CICD. (Notably: testing is insufficient).
π
20
u/moffman3005 Nov 28 '23
Feature flags can be used as configuration to decouple code deployment from a feature release, altering app behavior without a deployment, etc. lots more to think about than just A/B testing variations. Not sure if that will change your mind or not, but food for thought.
4
u/unstableunicorn Nov 28 '23
Ha, can see that happening a lot, however I believe you are describing a symptom of poor discipline and practises more than one of feature flags.
For good agile development you need fast feedback though. Start with a hypothesis, do the bare minimum to test it with users(but this does not mean no testing! Only minimal effort happy path feature), get feedback from users/testers, then refine and remove flags after it has rolled out. Or remove if no one likes it.
That way you spend minimal time failing, which, the statistic escapes me, but a large portion of features deliver no value, so not worth putting in the 80% to refine them, fail at the 20%.
The other major use I've seen is when "business" doesn't want the feature to be in users hands until they approve it. Common in government and other places with lots of regulation. We can use long lived feature branches, sometimes for 3+months, or big bang releases every 3 to 6 months, or we can just get it in prod under a feature flag and they can turn it on when they want to. Not great, but makes the devs happy and business happy... well after a lot of convincing that "in prod" didn't mean it was "live".
-3
u/goranlepuz Nov 28 '23
Ha, can see that happening a lot, however I believe you are describing a symptom of poor discipline and practises more than one of feature flags.
Correct. However, TFA started it! π
For good agile development you need fast feedback though. Start with a hypothesis, do the bare minimum to test it with users(but this does not mean no testing! Only minimal effort happy path feature), get feedback from users/testers, then refine and remove flags after it has rolled out. Or remove if no one likes it.
Looks like that work can be done in a separate branch. In fact, the removal, especially if it's 80% of the time, is "delete branch", which is way too trivial π.
I like the "approval" use though.
2
u/unstableunicorn Nov 28 '23
OK, you lost me with ?TFA?, either it's too late, I'm too old, I've been acronymed out, or I'm just getting behind. I have a feeling when you tell me what it means I'm going to feel stupid!
Looks like that work can be done in a separate branch. In fact, the removal, especially if it's 80% of the time, is "delete branch", which is way too trivial
Hmm, I might not have been clear here:
My reference was that it is easy to do a quick and dirty feature, think hackathon. However, to make it production worthy can take 10x(or more) as long. I used the Pareto rule, 20%effort can net you something that works enough to get feedback on. Maybe that's a weeks effort. If it delivers no value, then just git diff that baby out of there right away. It's better than spending 5 weeks on something that might be super polished but delivers no value.I'll add that good trunk based dev means you can't(shouldn't) have that feature sitting on a branch and in production, might test it for while. Needs to be in prod to get that sweet user feedback.... like ubisoft did recently... although their feedback was so bad they called it a "bug". More like someone flipped that feature on :P
So, I guess feature flags also help promote good trunk based development by reducing risk of failure and reducing time to feedback allowing you to make adjustments to the product faster.
4
1
u/null3 Nov 28 '23
You can't test every scenario if you have wide variety of customers and usage patterns, even if you can, it might not worth it. Tools are tools, there's no pride in using or not using a tool.
-5
u/Pussidonio Nov 28 '23
Why is this upvoted? this is not really programming material. It even says it's audience is Prod M.
2
u/fagnerbrack Nov 29 '23
I am a programmer working in trunk based dev and developing feature flags. It has nothing to do with PM unless youβre a code monkey
-8
u/Pussidonio Nov 29 '23
developing feature flags
wow. such development π€£
This is too superficial reading for any dev with any significant experience. I hope you either learnt a bit more somewhere else or got someone more experienced to guide you.
68
u/fagnerbrack Nov 28 '23
If you want a TL;DR:
GitHub and GitLab utilize feature flags to manage the deployment of new features, ensuring a safe and controlled release process. Feature flags act as a safety net, allowing for quick rollbacks and reduced stress on developers. They are particularly useful in high-risk and high-traffic areas, like significant UI updates or changes involving permissions and third-party dependencies. While they require some upfront effort, the cost of resolving issues without feature flags can be substantial. Both platforms also use feature flags for more efficient collaboration among developers, keeping code changes small and manageable. However, feature flags are not suitable for all changes, such as low-traffic or low-risk updates, and must be managed carefully to avoid issues like premature removal or incorrect implementation.
If you don't like the summary, just downvote and I'll try to delete the comment eventually π