A lot of people talk about code smell, what it is, how to detect it and anti-patterns. However, the thing that struck me today was this: I was out mowing the yard. The temperature was like a billion degrees, it was humid and I was mowing uphill no matter which way I turned! So basically, it was hard work. The thing that struck me was that I hit a section of air that smelled like a fragrant fabric softener. It really perked me up. I felt rejuvenated and mowed with more gusto. I looked forward to returning to the portion of the yard that had the scent in the air.
That got me thinking about code smell. Besides code taking us more time to work through because of quality issues, there is also the issue that it smells! It is repulsive, it is repugnant, it is de-motivating! Who wants to go work on the smelly code? No one wants to do it. It is like being told to retrieve a book that is in a library that is located in the middle of a landfill. No one wants to do that. I think there is a psychological aspect of smelly code that should be considered. That is, people want to stay away from stinky code.
On the flip side, are you excited when you get to go work in clean code? Code that is well factored, code that uses patterns, code that you can understand, code that is a joy to work with. I know that I can honestly say that if I have an application to work on and I know that it exhibits the qualities above, has a good design and has a reasonable amount of documentation I get excited about working on it.
Also, when I’m working in clean code I don’t want to be the one that dirties it up—regardless of who wrote it.
In conclusion, I would counsel that messy code besides having quality issues is also de-motivating. Clean code, good smelling code is a joy to work with. Strive for clean code.