The boy scout rule
Robert (Uncle Bob) Martin is a founder of the agile manifesto and a rockstar among developers.
In his speeches he teach and inspire developers to improve their design and code skills.
I try my best to follow his principles, and here I present you one of my favorite:
It’s not enough to write the code well. The code has to be kept clean over time. We’ve all seen code rot and degrade as time passes. So we must take an active role in preventing this degradation.
The Boy Scouts of America have a simple rule that we can apply to our profession.
Leave the campground cleaner than you found it.
If we all checked-in our code a little cleaner than when we checked it out, the code simply could not rot. 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.
This holds true even in the absence of good code structure. If you work on a legacy project and you find code that is unclear or without tests, don’t just do the fix or add the feature, take a little time to improve the code: refactor a method, add some tests, split classes, code toward respecting the SOLID principles.
See http://www.informit.com/articles/article.aspx?p=1235624&seqNum=6