Boy Scout Rule

Leave Your Code Better Than You Found It

When boy scouts go camping, they have a rule that they should leave the campground cleaner than when they found it.

By leaving the campground cleaner than when they left if when they arrived, they can guarantee that they are doing no harm in terms of cleanliness.

Software is very tricky, when does it make sense to spend time working to improve the design of the code base? Over time software degrades and you gain technical debt and stakeholders never seem to understand why a team needs to invest in technical debt

Some teams will try to shut all feature development down and tackle technical debt but this is becoming increasingly difficult in a feature-driven product development domain.

Another approach is the boy scout rule:

Try and ensure that with each commit, you leave the code better than you found it.

Maybe, over time, if teams follow this principle, they can improve the quality of code over time whilst delivering value to end users and stakeholders.

The act of leaving a mess in the code should be as socially unacceptable as littering.

— Robert C. “Uncle Bob” Martin