Lesson 2 of 4
Retire a Flag That Stopped Deciding
Estimated time: 10 minutes
A flag earns its place while it decides between an old path and a new one. Once the new path is the only one running, the flag decides nothing, yet it stays in every branch that reads it and every reader must still be traced to know what the code does.
Treat the full on state as the target. Give every flag an owner and an end date from the day it is added, and remove it once it is always on. The branch it guarded goes with it, which is the real saving.
Keep a small, separate set of flags that exist only to switch something off in an emergency. Those are meant to be read rarely and stay; everything else is a rollout flag on its way out.
def audit(flags, today):
return [f for f in flags
if f['changes'] == 0 and f['end_date'] < today]
Review the list on a fixed schedule. A flag list that is never read is where settled flags go to hide.