Being a dog, Hannah isn't particularly fussy about where she, um, takes a bio-break. Now, we could simply look the other way and pretend that we didn't see what just occurred but, again, she's a big dog. Since we follow a couple of well-worn routes around our neighbourhood and in the park behind, the accumulation of doggy doo would be quite significant very quickly. Add to that all the other dogs, large and small, in our area and you would have piles upon piles of... I think you get the picture.
So, being the good citizens that we are we stoop and scoop, cleaning up the mess right there on the spot. We diligently take it back home in a plastic bag and toss it in the garbage. Most of our neighbours do the same, and the area is the better for it. There have even been times when we've cleaned up the mess from other dogs whose owner were not quite so diligent, all for the greater good of our neighbourhood.
Imagine for a moment that the code in which you work is your neighbourhood. When you are adding new code or making changes, do you want to be stepping in all the crap that other dog... er, code owners have left? Do you think they want to step in the crap you 'neglected' to see because you looked the other way when your dog decided to stop?
Of course not.
When you're writing code, do the equivalent of stoop and scoop. Ask yourself if the code you're writing, be it production code or tests, is adding crap to the neighbourhood. If it is, clean it up! I'm OK with the idea of getting the code to work and then refactoring to improve the design, but I can say from experience as both a programmer and dog owner that the smaller the pile of crap you have to clean up, the easier it is on the senses.
For the 'how' part of cleaning up the code, Joshua Kerievsky's Refactoring to Patterns is an excellent place to start. His company, Industrial Logic, also published a cheat sheet for Code Smells to Refactorings that is a very helpful starting point for identifying what's smelly about the code and patterns for how to remove the smell. These are small, stoop and scoop steps that will help you to prevent the construction of a large pile of crap that does nothing but smell!
So remember, other people have to live in the same neighbourhood as you. Be a good neighbour - stoop and scoop your code!
(Please note - any "this is a crappy blog post" comments will be summarily marked as spam! :)