Member-only story

The Boy Scout Rule in Coding

Leave it better than you found it

--

Photo by Gilles Trenson on Unsplash

Keeping your code maintainable and easy to read is an incredible challenge. Can you rise to that challenge, and even maintain the Boy scout rule?

The scout’s rule

Robert Baden-Powell is attributed with the following quote

Try and leave this world a little better than you found it, and when your turn comes to die, you can die happy in feeling that at any rate, you have not wasted your time but have done your best.

This has been interpreted when scouts camp with the following:

Always leave the campground cleaner than you found it

Which is nice isn’t it?

When the scouts camp somewhere, it doesn’t matter who dropped some litter on the floor — even if it was someone who isn’t in the scout troop.

The effect of a rule like this is manyfold, but one result of this is that the scouts get a good reputation wherever they go. They are seen as some sort of force for good, and have a rule that is simply to conform to.

They even make it fun to follow the rules (have a pitch-check at the end of the camp).

Uncle Bob’s interpretation

Uncle Bob (Robert C. Martin) has further interpreted the quote as:

Always leave the code you’re editing a little better than you found it

and…

Indeed, the act of leaving a mess in the code should be as socially unacceptable as littering. It should be something that just isn’t done.

As software is developed and evolves over time technical debt is said to increase. Members of staff change, and yet the code stays the same and features are added onto the code.

Keeping code in good condition and clean makes sense, and code should represent your understanding of the code at any given…

--

--

No responses yet

Write a response