DEV Community

Sreekar Reddy
Sreekar Reddy

Posted on • Originally published at sreekarreddy.com

🚩 Feature Flags Explained Like You're 5

Toggle features without deploying

Day 143 of 149

πŸ‘‰ Full deep-dive with code examples


The Light Switch Analogy

Every room has light switches:

  • Flip on β†’ Light works
  • Flip off β†’ Light doesn't work
  • No need to rewire anything

Feature flags are light switches for code!

Turn features on or off without deploying new code.


The Problem It Solves

Traditional deployment is all-or-nothing:

  • Deploy β†’ Everyone gets the new feature
  • Bug found? β†’ Roll back everything
  • Want to test with some users first? β†’ Can't easily do that

How Feature Flags Help

With feature flags:

  • Deploy code with flag OFF β†’ Feature hidden
  • Turn flag ON for 10% of users β†’ Test it
  • Everything working? β†’ Turn ON for everyone
  • Problem found? β†’ Just flip it OFF

No redeployment needed!


Common Uses

Gradual rollouts:

Week 1: 5% of users
Week 2: 25% of users
Week 3: 100% of users
Enter fullscreen mode Exit fullscreen mode

Beta testing:

  • Flag ON for beta users
  • Flag OFF for everyone else

Kill switches:

  • Feature breaking production?
  • Flip the flag OFF instantly

A/B testing:

  • Version A for some users
  • Version B for others
  • See which performs better

A Simple Example

if feature_flag("new-checkout") is ON:
    show_new_checkout()
else:
    show_old_checkout()
Enter fullscreen mode Exit fullscreen mode

Toggle it from a dashboard:

  • No code changes
  • No deployment
  • Instant effect

Benefits

  • Lower-risk releases β†’ Test with small groups first
  • Quick fixes β†’ Turn off misbehaving features quickly
  • Flexibility β†’ Different features for different users

In One Sentence

Feature flags let you turn application features on or off for specific users without deploying new code.


πŸ”— Enjoying these? Follow for daily ELI5 explanations!

Making complex tech concepts simple, one day at a time.

Top comments (0)