If you are a developer working in a corporate environment, chances are that you work in an object oriented system. Java and C#, along with old uncle C++ have the industry by the gonads. Great OOP developers are critical to the success of any company that develops OO software. Why is it so hard to find great developers? Why is most object oriented code a mess that people hate having to work with?
Sweat now, gain later
My theory is simple. We value what the code does more than we value how the code looks. It’s a little bit like watching TV or working out. If you stay home and have a soda in front of the TV, your rewards are immediate. You’ll relax, and the sugar feels good. Anything uncomfortable that might come from sodas and TV will not affect you for a long time. Working out, on the other hand, is often uncomfortable immediately. The sweat comes now, the nice abs way down the line. So why bother?
Code now, test later
This leads to legions of developers and managers that put short term rewards ahead of long term benefits. Hacking away without unit tests or stopping to refactor gives you that immediate reward of working code. Working diligently on great code design won’t give you any benefits until much later. It’s way too easy to use that path. I’ve been thinking about code quality for years now, and I still start hacking away if I don’t watch myself.
You get what you measure
I think that there is one more factor that makes bad code so common. Whether code works or not is relatively easy to measure. You click a button, and either the row is put into the database, or it’s not. It’s easy to see for anyone, including managers, product owners and clients. Code quality is, on the other hand, impossible to measure, and to a large degree a subjective dimension. So anyone trying to measure output from a developer, can measure finished story points with ease, but has a hard time measuring code quality.
The old maxim says that you get what you measure. And I’ve seen almost every team I’ve met measure their productivity on the complete features axis, but few or none measure the quality of their code.
We’re heading for a fall
I wish I had something more positive to finish this post of with. We are as a species fighting a losing battle against obesity, and I don’t think we’ll finish any better in the battle against bad code. The only silver lining is that any team that has the wisdom and discipline to do what it takes will easily outrun the lazy developers that prefer TV over the treadmill.
Nice thoughts and I do recognise myself in a lot of what you write.
I think it becomes easier if this this focus becomes a team commitment and not only an individual responsibility. A company should should invest time for dedicated meetings in order to discuss such things. This way you feel both the responsibility and the support from team members to actually do good.
At the Admeta company, I’ve started a Clean Code study circle with the purpose of exactly this having one hour each week that we meet. One hour every other week for Clean Code book discussions (details in my blog) and one hour every other week for other types of discussions/presentations. I think we see the fruits of this already at our company with a different mindset and more enthusiastic athmosphere.
No man is an island.
PS. How do you measure code quality? Are there any good advices to get here?
Left by Tobias FjÀlling on February 26th, 2009
You are right there.

And I’m starting to recognize myself, with Tobias too.
What to do it this case?
I think that nowadays you are no one if you aren’t working on yourself and don’t try to overcome your lazyness and other faults.
Just try to form your team of persistant, hard working developers. And stimulate them for who they are, what qualities they have and their progress on themselves.
Left by Iflexion web developer on March 13th, 2009
I agree..
We talk often about, time is money, but that is in the short term not in the long term.
For the moment I am somewhere between the lazy fizzy bubbliz driking coder, and sometimes I train very hard.
Left by Fredrik M on March 23rd, 2009
You got me!
I thinks this post is a wake up call for all those developers who doesn’t even care about the way they code.
The way they work is the biggest hindrance to achieve the success of a project.
It also affects the other team player’s productivity and efficiency.
Wake Up dude! burn some fats!
Left by Lu Xun on October 21st, 2009