Are you a Boy Scout?

A look at how the simple practice of "boyscouting" can improve your code.

Posted in Main Thread on January 1, 2015

About a year ago Samuel Goodwin left a commit message of “Boyscouting”. When I asked him about the commit he reminded me of the Boy Scouts motto [1]:

Leave it better than you found it.

Applied to development, this meant eliminating dead code, removing comments, and standardizing format. Samuel did this before he made changes.

Since then, I have tried to follow this practice [2]. It requires discipline. Not only in routine, but in restraint. It’s tempting to add other changes to your “Boyscouting” commit.

It is important to understand boyscouting does not change code, only cleans it. Boyscouting is not refactoring. Boyscouting is not fixing bugs.

When in doubt, see if your boyscouting passes this test:

Would reverting the commit result in code loss?

If so, then you’ve done more than boyscouting. Commits are cheap. As shown in the screenshot, separate changes into their own commit.

Boyscouting Commit

Practicing something as simple as boyscouting not only improves the codebase, it improves my development. I no longer waste time on dead code or fixing formatting. Instead I can focus on making changes and use any extra time to improve the code further.

Share the practice of boyscouting with others as Samuel did with me. Boy Scout your code!

If you’re wondering about the icons next to the commit hashes check out Mergeatron.

[1] As pointed out by SwabTheDeck on reddit and Neal in the comments this is not the Boy Scout motto, but a passage left by Robert Stephenson Smyth Baden-Powell, founder of Scouting.

[2] Upon researching the Boy Scout motto, I also came across The Boy Scout Rule in 97 Things Every Programmer Should Know.

Find this interesting? Continue the conversation on Twitter or in a comment.

Need more? Let's team up!

Schedule 1-on-1 coaching or hire me for your project.


comments powered by Disqus