Coding Principles



minutes read

Boy Scout Rule



September 19, 2022

feature image
🏕️ The boy scouts have a rule - “Always leave the campground cleaner than you found it.” If you found a mess in the ground, you clean it up regarding who made it, improving the environment for the next groups of campers.

The codebase is the developers’ campground

Writing good codes is simply not enough. As code rots one line at a time, it has to be kept clean over time to maintain quality.
If all developers checked in the codes a little cleaner when they checked it out, the code simply could not rot.
Cleaning up the campground may sound like a big deal, but it actually takes less than you think.

a vince mcmahon meme of a co-worker act of kindness level when doing code review

The campground clean up check-list

Code cleanup should be limited to the files you work with, don’t go overboard with it. Here are some small yet powerful things you can do to clean up your campground:

  • Update the document: Whether it is adding a comment explaining a tricky code, or just simply fixing a typo, this is a good place to start improving the codebase because it has minimal impact on the actual code.
    You can also help out by removing old, crusty docs. If there is a comment that no longer applies, remove it. If there’s cut and paste documentation that doesn’t apply, get rid of it. That cleans up the code for the next person to come along (who might be you).
  • Improve a test (or write a new one): Tests help you write maintainable, extensible code that others can change without concern. If you come across untested code, make sure you write a test before checking out.
  • Refractor it: Refactoring code can range from renaming a variable to overhauling an entire module. Start small and don’t get wrapped up in perfection. Make the code clearer in intent.
    If you spot code smells, it’s best to refactor the code. But be careful when refactoring what you don’t understand, especially if the code is untested, you still need to make sure that it still worked properly.
  • Upgrade a dependency: If you don’t actively manage dependencies, your project can go sideways fast. The entire application may fail to benefit from newer technologies due to the older dependencies holding it back. So better prevent than sorry.


You don't have to make the code perfect before checking out, you simply just need to make it a little bit cleaner than when you checked it out. These small actions not only help others as they improve the overall code quality but also provide examples for other developers on how to do so.

Until next time, happy coding, folks! And remember to leave the code in a better place when you found it!