May 26, 2011

The Boy Scout Rule

During the last couple of weeks I've been reading 97 Things Every Programmer Should Know online, it's a great book full of interesting and enlightening articles.

One that stuck to me in particular was #8 - The Boy Scout Rule. From the real-life Boy Scout rule "always leave a place cleaner than you found it", Robert Martin proposes a parallel to programming projects:

Always check in a module cleaner than when you checked it out.

Not making the code perfect, but taking a few moments to clean something up, whether it be abstracting a long method into several methods, documenting a line of obscure code, or changing a variable name to be more clear.

This way, rather than a codebase becoming messier and more outdated over time, it would be more maintainable and lead to a team working together to help improve eachothers' code (and actually knowing how other peoples' parts are implemented).

What a refreshing concept.