Feature Flags: Qu' lIj
feature flag conditional ghaH, code Dung wrap: code on pagh off (Hoch vaD, user subset vaD, pagh gradual) - deploy chu' pagh. yIch Dun: if Hoch codebase Daq. 'ach scale Daq Qagh. Dun vaj deploy code 'ej release pIm. Qagh vaj dead branches labyrinth, vay' Qaw' Dar pagh.
simplest version
feature flag boolean check:
if (flags.isEnabled('new-checkout-flow', { userId: user.id })) {
return renderNewCheckout();
}
return renderLegacyCheckout();
if Dun pagh - flags.isEnabled. answer nuqDaq? chay' nom choH?
flag evaluate wej mIw
Static config. JSON pagh YAML file, environment variables, deploy time check. implement Dun 'ach flag choH redeploy poQ - toggling nom, risk Dach Qaw'.
const flags = { 'new-checkout-flow': process.env.FF_NEW_CHECKOUT === 'true' };
Remote flag service, runtime Daq query (cache), dashboard vo' flip, deploy pipeline touch pagh:
async function isEnabled(flagKey, context) {
const cached = cache.get(flagKey);
if (cached) return evaluate(cached, context);
const flag = await flagService.fetch(flagKey);
cache.set(flagKey, flag, { ttl: 30_000 });
return evaluate(flag, context);
}
Percentage pagh attribute rollout, flag on/off neH pagh, traffic slice target - user 5%, pagh plan === 'enterprise':
function evaluate(flag, context) {
if (!flag.enabled) return false;
if (flag.rolloutPercent != null) {
const bucket = hashToPercent(context.userId, flag.key);
return bucket < flag.rolloutPercent;
}
if (flag.rules) {
return flag.rules.every((rule) => matchesRule(rule, context));
}
return true;
}
function hashToPercent(userId, flagKey) {
const hash = simpleHash(`${userId}:${flagKey}`);
return hash % 100;
}
hashToPercent qatlh: userId hash (request random pagh) - user wa' side reH flag Daq. pagh vaj checkout flow chu' wa' request, old pIm request (Qagh, bugs reproduce Qatlh).
flags nuq vaD
Release flags deploy release pIm: code merge 'ej ship dark, on flip. Experiment flags A/B test: user percentage variant B, difference measure. Ops flags kill switches: slow non-critical feature off load Daq, deploy pagh. Permission flags feature user pagh plan Daq gate (enterprise-only). long-lived access control vaD entitlements system Dun.
type Hoch lifecycle pIm. Ops flags reH laH. Release 'ej experiment flags Qo'.
Hoch skip: delete
flag 100% jar wej, old behavior check code path pagh - safety pagh. dead weight: codebase laD Qatlh, change Hoch risk law'. cha' paths reason.
// Six months later, this still exists:
if (flags.isEnabled('new-checkout-flow')) {
return renderNewCheckout();
}
return renderLegacyCheckout(); // dead code nobody has run in months, still shipped, still maintained
flag cleanup definition of done Daq. flag rolled out 'ej stable vaj flag check 'ej dead branch Qaw'. teams linter lo' (N jaj law' flag check), dashboard (flags toggled pagh).
Qagh: flags interact
cha' flags independent legh 'ach combine state test pagh:
if (flags.isEnabled('new-checkout-flow')) {
if (flags.isEnabled('new-payment-provider')) {
return renderNewCheckoutWithNewPayments(); // did anyone actually test this combination?
}
return renderNewCheckoutWithOldPayments();
}
flag chel Hoch code paths double. cha' flags = loS paths; wej = chorgh. flags narrow 'ej short-lived. combinations nuq support Sov. Hoch combination test realistic pagh (flags law' same area).
yaj
Feature flags code ship release pagh, gradual rollout, misbehaving feature kill deploy pagh - value ghaj. failure flag pagh - flags permanent legh. flag Hoch debt: delete. debt pay pagh codebase flags pagh Dung Qatlh.