How can i implement feature flags cleanly in the backend?
#1
I'm trying to implement a simple feature flag system for my web app's backend, but I'm struggling with how to cleanly check the flags without scattering conditionals everywhere in the code. My current approach feels messy and makes the logic hard to follow.
Reply
#2
I rolled a tiny feature flag service. It reads toggles from a JSON file on startup, caches them, and you call isEnabled('newCheckout') in code. It helped keep the code cleaner than a thousand scattered ifs, but I still hit trouble when those toggles ended up in constructors and varied defaults.
Reply
#3
It did help me see where the logic was spreading, but we ended up with a separate module and still sprinkled checks in routes and service methods. Not great, but at least there was a single place to adjust defaults.
Reply
#4
Do you actually need per user toggles, or would a global switch cover most cases? I keep running into user scope creeping into too many modules and it becomes a maintenance mess.
Reply
#5
I started sketching a tiny DSL for toggles, then got pulled into configmaps and deployment environments. It felt glorious for a minute and then ridiculous for a small backend. Anyway, the core remains about keeping the decision points visible without duplicating code.
Reply


[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Forum Jump: