Beware The Boy Scout Rule

By | February 15, 2018

Cup of hot coffee

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.

Clean code rules should not override common sense.

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

Why? 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. 🙂

Leave a Reply

Your e-mail address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.