• Matt Burrell

Beware The Boy Scout Rule

I’m a big fan of rules of thumb in software development.

They help us understand and apply good principles of software design.

Here are a few useful ones:

  • Keep it simple, stupid

  • You ain’t gonna need it

  • Don’t repeat yourself

  • Tell, don’t ask

  • Don’t polish a turd

Ok, I added the last one myself…

The rule of thumb that concerns me, however, is the so-called ‘Boy Scout Rule’:

“Always leave your code better than you found it”

This is dangerous advice because “better” is a subjective term. Let’s assume by better we mean cleaner. All developers have read Clean Code, right?

The trouble arises when developers apply clean code rules without using their common sense.

In their effort to leave code better than they found it (refactoring), I find that some developers, despite their good intentions, leave the codebase in a much messier state.

This happens because they end up writing a lot more code.

This usually violates some or more of the other principles, e.g. Keep it simple, stupid, You ain’t gonna need it and, of course, Don’t polish a turd.

Happy coding.