Boy scout habit

Published on 13 June 2013.

Today’s though is about a habit that can help you enforce the boy scout rule.

The boy scout rule says that you should always leave the camp ground cleaner than you found it. Applied to software, that means always leaving the code base in a better, cleaner state than you found it.

The idea is simple, but harder to implement in practice. After you have made your change to the code base and tested it, you feel like you are done. After all, it is working. It’s easy to stop here. But if you didn’t clean up surrounding code while you implemented your change, you did not leave the code base in a cleaner state. At best, you didn’t make it worse.

To avoid that this happens, an idea would be to start with refactoring. Clean up the code you need to change before you actually make the change. That is the habit.

The refactorings doesn’t have to be big. It just has to be something that makes the code cleaner.

Benefits:

What is Rickard working on and thinking about right now?

Every month I write a newsletter about just that. You will get updates about my current projects and thoughts about programming, and also get a chance to hit reply and interact with me. Subscribe to it below.