Jens Oliver Meiert

Boyscout Code

Post from July 20, 2017, filed under .

Still evaluating and normalizing feedback for the great maintainability survey I’ve so far worked through a ton of excellent comments. All of it will, in a comprehensive fashion, make for a new, updated web maintainability guide, and yet one particular aspect resonated so well with me that I wish to call it out again specifically: the boyscout approach to code.

This approach resurfaced after one of our peers commented the following on “What techniques do you find useful to keep websites maintainable?”: “Refactoring every time you touch something and see potential for improvement.”

We’ve probably all been there at some point, when we saw something and fixed it (a googley principle), and so I instantly nodded, “yes, that’s a great habit.” It reminded of the boyscout credo, attributed to Robert Baden-Powell, to

Leave this world a little better than you found it.

or, more specifically,

Always leave the campground cleaner than you found it.

This does work so well for code that—formerly (though certainly not unsurprisingly) unbeknownst to me—it had long been quoted by Robert Martin in, exactly, The Boy Scout Rule:

Always check a module in cleaner than when you checked it out.

…which we could, and I’ve included this in my errata for The Little Book of Website Quality Control, rephrase to simply say:

Always leave code better than you found it.

This is not new, either, but it’s how I’d prefer to spell out the boyscout rule. Always leave code better than you found it.

As I said, there’s progress with the new, survey-inspired maintainability guide; stay tuned on Twitter or through one of this site’s feeds (subscribe just to my developer feed if the rest is not of interest to you).

The first rule of good coding: If something’s broken, fix it.

Figure: I couldn’t help it.

About the Author

Jens Oliver Meiert, photo of July 27, 2015.

Jens Oliver Meiert is a developer (O’Reilly, W3C, ex-Google) and philosopher. He experiments with art and adventure. Here on meiert.com he shares and generalizes and exaggerates some of his thoughts and experiences.

There’s more Jens in the archives and at Amazon. If you have any questions or concerns (or recommendations) about what he writes, leave a comment or a message.

Read More

Have a look at the most popular posts, possibly including:

Or maybe say hi on Twitter, Google+, or LinkedIn?

Looking for a way to comment? Comments have been disabled, unfortunately.

Flattr? Found a mistake? Email me, jens@meiert.com.

You are here: HomeArchive2017 → Boyscout Code

Last update: July 20, 2017.

“If there is any secret, it is missed by seeking.”