Leave It Better Than You Found It
Robert C. Martin (widely known as "Uncle Bob") adapted the Boy Scouts of America's campsite rule for software development:
"Always leave the code cleaner than you found it."
This is not about heroic rewrites. It's about micro-improvements applied consistently over time. The math is straightforward: if every engineer on a team of 8 makes one small improvement per pull request, and the team merges 10 PRs per week, that's 520 micro-improvements per year. Entropy doesn't stand a chance against that rate of repair.
What "better" looks like in practice:
You're assigned a ticket: "Fix bug where email notifications send duplicate messages." You open notification_service.py and find the bug on line 47. But you also notice:
# Before: What you found
def send(self, u, t, msg, flag=True, x=None):
# TODO: refactor this (added 2021-03-14)
if flag:
if x is not None:
self._do_send(u, t, msg, x)
else:
self._do_send(u, t, msg, "default")
else:
pass # not sure why this branch exists
A junior engineer fixes the duplicate-send bug and moves on. A senior engineer fixes the bug and spends 10 extra minutes:
# After: What you left behind
def send(self, user_id: str, template: str, message: str,
enabled: bool = True, channel: str = "default") -> None:
"""Send a notification to a user via the specified channel.
Args:
user_id: The recipient's user identifier.
template: The notification template name.
message: The message body to deliver.
enabled: If False, the notification is suppressed. Defaults to True.
channel: Delivery channel (e.g., 'email', 'sms'). Defaults to 'default'.
"""
if not enabled:
return
self._do_send(user_id, template, message, channel)
The changes: meaningful parameter names, type hints, a docstring, removal of the dead else: pass branch, and simplification of the conditional logic. Total extra time: 10 minutes. Impact: every future developer who reads this function saves 5 minutes of confusion. After 20 developers read it, you've saved the organization over an hour from a 10-minute investment. The return on investment compounds indefinitely.
How to make this sustainable:
- Keep cleanup commits separate from feature commits. Use a commit like
refactor: clarify parameter names in NotificationService.send()separate fromfix: prevent duplicate email notifications. This makes code review easier and keepsgit blameuseful for future debugging. - Set a time box. The Boy Scout Rule is not "rewrite the file." It's "spend 5–15 minutes improving what's nearby." If the mess is bigger than that, create a ticket and link it in a comment.
- Make it a team norm, not a personal habit. Discuss it in code reviews. When someone applies the rule, acknowledge it explicitly. Culture is built through repetition and reinforcement, not through a one-time announcement in a team meeting.
Key Point: The Boy Scout Rule works because it distributes the cost of maintenance across every commit, making it invisible in any single PR but transformative over months. The alternative — ignoring small messes until they require a dedicated "cleanup sprint" — is always more expensive in total cost and often never happens because there is always a more urgent feature to ship.