Skip to content

Lesson 1 of 9 · 24m

Feature Flags Are a Decision System, Not an If Statement

Understand flags as distributed runtime decisions with owners, lifetimes, evaluation context, and consequences far beyond a boolean branch.

The worst flag systems begin as convenience. A developer wraps a risky change in if new_checkout: and everybody feels safer. Six months later there are four checkout implementations, nobody knows which one is canonical, and removing the flag is scarier than the original release. A flag is not a conditional. It is a runtime decision with an audience, a blast radius, an owner, and a planned death.

Start with the decision, not the implementation

A useful flag definition answers five questions before any code is written:

key: checkout.payment-orchestrator
owner: team-payments
type: migration
default: false
expires: 2026-03-15
risk: high
rollback: disable flag; no deploy required

Notice what is missing: implementation detail. The important part is the decision contract. Who is exposed? What happens when evaluation fails? Who can change the value? When does the decision stop being a decision?

Flags multiply system states

Two independent booleans create four combinations. Twenty create more than a million. You will never test the full matrix, so the practical goal is to constrain which combinations can exist. Group related behavior behind one well-named flag instead of inventing new-ui, new-ui-copy, new-ui-copy-v2, and enable-final-copy across three teams.

if flags.enabled("checkout.payment-orchestrator", user):
    return orchestrator.authorize(order)
return legacy_gateway.authorize(order)

This is a migration decision. It should route the whole workflow. If the payment authorization is new but capture is old because another developer reused half the flag, you no longer have progressive delivery — you have distributed roulette.

Separate server, client, and edge decisions

The same key evaluated in different places can produce different truth. A mobile client may cache a value for hours, a server may evaluate per request, and a CDN worker may evaluate before authentication. Decide where authority lives:

edge       coarse routing, geo, bot control
server     authorization-sensitive behavior, data mutations
client     presentation, latency-sensitive UX
offline    rare, explicitly documented behavior

A security-sensitive backend rule must never depend on the client-side value. The client can render a button; the server still decides whether the operation exists.

Make the default intentional

default: false means the world continues when the flag service is down. Sometimes the safer default is true, especially for protective behavior such as stricter validation. Do not cargo-cult false. Ask which failure mode hurts less: losing the new path or losing the protective path.

Field notes

  • If nobody can say who owns a flag, the organization owns the outage it will eventually cause.
  • Do not let flag names become commit messages. fix-crash-2 tells future engineers nothing about scope or lifetime.
  • A flag that controls both read and write paths is usually too broad; split it at the trust boundary.
  • Temporary flags deserve expiration dates before the first pull request, not after the launch review.

Was this lesson helpful?

Sign in to rate