The Boy Scout Rule
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.”
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 RSS. I personally use Feedly; you can subscribe here.
Maybe you have something to say. You can comment below, email me, or toot at me. I love feedback. I also love gigantic compliments, so please send those too.