The Boy Scout Rule

Friday 22 January 2016 at 08:00 GMT

The Boy Scouts have a rule: "Always leave the campground cleaner than you found it." If you find a mess on the ground, you clean it up regardless of who might have made the mess. You intentionally improve the environment for the next group of campers. Actually the original form of that rule, written by Robert Stephenson Smyth Baden-Powell, the father of scouting, was "Try and leave this world a little better than you found it."

by Robert C. Martin

Yesterday, I wrote about code comments. It's my opinion that most code comments suck. They're misleading, wrong, and most importantly a side effect of laziness. Comments like this:

x += 7.5 // number of hours in a working day

Or this:

// For some reason there is a race condition in `updateTotal`.
// The odds of it happening twice are really low though.
updateTotal();
updateTotal();

Or, worst of all, this:

// TODO fix for Sundays
calculateEmployeeOvertime();

These comments make the code worse. Rather than fixing the root cause, the developer has chosen simply to document the problem.

Don't be that developer. Leave this world a little better than you found it.

Follow the Boy Scout Rule.


If you enjoyed this post, you can subscribe to this blog using Atom.

Maybe you have something to say. You can email me or toot at me. I love feedback. I also love gigantic compliments, so please send those too.

Please feel free to share this on any and all good social networks.

This article is licensed under the Creative Commons Attribution 4.0 International Public License (CC-BY-4.0).