Clean code is an important quality, but not the MOST important

Clean code is a book by Uncle Bob Martin that speaks to principles in software development that lead to high quality, legible software. This is a great book and every developer should read it once (or twice). The book outlines important tools and techniques, but these are not the end, they are a means. I've noticed a lot of folks treat clean code as the "secret sauce" that makes great software. Unfortunately, they take it a little too far and by being too focused on their secret sauce, they forget that it's worthless if the customer starves to death waiting for the secret sauce to be "perfect".

At one point early in the book, Uncle Bob uses the metaphor of physicians and hand washing. In particular, he makes a point that it would be unrofessional and possibly illegal for physician to not wash his hands before surgery, even if the patient (the customer) asked for it. I like this metaphor and I think he makes a good point, but I feel he narrows the perspective too much. I respect his position, and it makes complete sense when talking about elective surgery, but doesn't apply in all situations. In my experience, most software development isn't like elective surgery with a controlled environment and a sterile operating room, but more like treating wounds in a combat zone under direct fire. In this sort of an environment, hand washing (clean code) is important, but not always as important as stopping the bleeding and/or saving the patient's life. It's often more important to get the patient out of harms way and stop the bleeding than it is to make sure you don't introduce the risk of infection at some future point. Sometimes, you might need to even sacrifice not only hand washing, but even a leg or two in order to save the patient's life and you've done the right thing.

The more important factor beyond keeping things clean is understanding and delivering value to the customer in a manner (i.e. cleanliness) that is appropriate for the environment. I've been on a few projects where there is 100% test coverage, the code is a beautiful work of art, but the business customer ultimately cancels the project because they cannot afford to operate without the business value the code was supposed to deliver. In our combat zone metaphor, some practitioners are so busy washing their hands, they've forgotten that the goal is to save lives, not prevent infection. Clean code is an important goal, just like preventing infection is an important goal, but not THE most important goal.

Developers, clean code is important, it is downright essential in the long run, but it is not the primary goal of software development. Learn the principles and techniques to keep your code clean, but don't forget that your customer needs the software to do something for them and no matter how clean your code might be, if it doesn't provide real business value in a timely manner, the customer isn't getting what they need. In other words, don't let your patients die from blood loss while you're busy washing your hands.

Comments

Hannibal said…
Nice article but there is no such thing as 100% code coverage ;)
Mike Mainguy said…
I would tend to agree, once there is one line of untested code in the operating system (or a device driver) I guess technically you've lost coverage.

Popular posts from this blog

Push versus pull deployment models

the myth of asynchronous JDBC

Installing virtualbox guest additions on Centos 7 minimal image