📖 Business
Biz - Boy Scout Rule
"Leave the campground cleaner than you found it." Applied to software: every time you touch a file, leave it a little better than you found it. Not a big refactor — just a small, continuous improvement. Rename a confusing variable. Extract a duplicated block. Add a missing test. Delete dead code. Fix a misleading comment. The Boy Scout Rule is Martin's answer to the question "When do we clean up code?" The answer: always, a little bit, as part of every change.
2
Minutes
2
Concepts
+45
XP
1
How It Works

What "a little better" looks like in practice:

  • Rename a confusing variable — you're already reading the code to make your change; if a name confused you, fix it.
  • Extract a duplicated block — if you find yourself copying logic, extract it into a shared function before moving on.
  • Add a missing test — if the code you're changing has no test, write one for the behavior you're modifying.
  • Delete dead code — commented-out blocks, unused imports, unreachable branches. Delete them. Version control has your back.
  • Fix formatting — inconsistent indentation, missing line breaks, overly long lines. Small fixes, big readability gains.

The compound effect: if every developer makes one small improvement per commit, code quality rises steadily without ever needing a dedicated "cleanup sprint" or "tech debt week." Over hundreds of commits, the codebase transforms.

The opposite — the Broken Window Theory: if code is already messy, people add more mess. A file with one bad name gets a second. A function with one hack gets another. Quality begets quality; mess begets mess. The first broken window is the most dangerous because it signals that nobody cares.

Martin's professional argument: craftsmen don't just write code that works — they write code that is clean. And they leave every file better than they found it. This is not heroism; it is daily discipline, like a surgeon washing their hands.