The Boy Scout Rule
The Boy Scouts have a rule: "Always leave the campground cleaner than you found it." What if we followed a similar rule in our code: "Always check a module in cleaner than when you checked it out."? What would be the result?
I think if we all followed that simple rule, we'd see the end of the relentless deterioration of our software systems. Instead, our systems would gradually get better and better as they evolved.
I don't think this rule is too much to ask. You don't have to make every module perfect before you check it in. You simply have to make it a little bit better than when you checked it out. Of course this means that any code you add to a module must be clean. It also means that you clean up at least one other thing before you check the module back in.
Frankly, this just sounds like common decency to me; like washing your hands after you use the restroom, or putting your trash in the bin instead of dropping it on the floor. Indeed the act of leaving a mess in the code as should be as socially unacceptable as littering. It should be something that just isn't done.
by Uncle Bob
This work is licensed under a Creative Commons Attribution 3
Back to 97 Things Every Programmer Should Know home page