DEV Community

Cover image for The Boy Scout Rule
mrosyidr
mrosyidr

Posted on

The Boy Scout Rule

This is one of popular clean code principles from Uncle Bob. You can find it on his book (Clean Code: A Handbook of Agile Software Craftmanship by Robert C. Martin. Chapter 1: Clean Code, page 14.)

"Leave the campground cleaner than you found it."

This was adapted from Robert Stephenson Smyth Baden-Powell’s farewell message to the Scouts: “Try and leave this world a little better than you found it . . .”

This principle is often used metaphorically in software development to emphasize the importance of writing clean, maintainable code and leaving the codebase in a better state than it was before making any changes.

Like what the scouts did cleanup in campfire, the software developers should implement this principle as well. The cleanup doesn’t have to be something big. Change one variable name for the better, break up one function that’s a little too large, eliminate one small bit of duplication, clean up one composite if statement. These improvements will make "our world" a better place.
...and it will guide us to clean coding.

Okay, then. Now what?

Happy Coding, Scouts! 🔥

Top comments (0)