Recently there was quite a bit of commotion in regards to code quality in the programming community. The commotion is between two of the most influential people in the programming community, Robert C Martin and Joel Spolsky. Just a brief recap of what happened.
It all started with a podcast by Scott Hanselman talking about SOLID principle with Robert C Martin (aka Uncle Bob). Founders of stackoverflow.com, Joel Spolsky and Jeff Atwood, heard the podcast and made a ad-homimem comment in stackoverflow podcast #38, stating that “Quality just does not matter that much”. Hearing this statement from a high profile developer with years of experience, made Robert Martin back flip. He wrote a blog to counter Atwood’s argument, and expresses his concerns. Joel Spolsky and Jeff Atwood decided to invite Robert Martin as a guest speaker in stackoverflow podcast #41. Before the podcast, Robert Martin posted another blog that acts as an open letter to Jeff and Joel that addresses all the issues he has with their comments.
After listening to all the podcasts and reading all the blog posts, it seems like to me that there’s actually a misunderstanding between the two party. When Jeff said “Quality just does not matter that much”, he did not mean it literally. What he meant was “Quality just does not matter that much when inexperience people try to apply programming principle religiously, that it slows down their productivity and produces no result.”. Joel and Jeff did not say that clearly enough in the podcast, that it sounded like a rather offensive comment towards Robert Martin.
I have to say that I’m 100% agree with Jeff statement. Inexperienced developer that overwhelmed by theories tend to forget that in the end the most important thing is the result. I remember when I first being exposed with design principles, it felt awesome to have learnt and understood something technical. I was so excited that when it came to solving a problem, I became more focused on how to apply the principle rather than actually solving the problem. Focusing more on applying a programming principle is a big problem, because you’re wasting time on something that does not necessarily solve the problem. In the end you did not get anything done and your work shows no result. It is very important to fully understand what programming problem does a principle solve, before we start using it.
So when is it appropriate to follow programming principles? After fully understanding the principle, we should always try to follow those principle whenever possible. Code that conform programming principles will be a lot easier to work with. For example, which one do you prefer, working on a class that is 20k lines long, or working with multiple classes with 2k lines each. I bet you prefer the multiple classes scenario. Even when time is a constraint, we can always try our best to follow good design principles. I think of it as an early investment. It may take a longer time to code a solution at first, but it will make it a lot easier to work with in the future.
Having said that, there are times that may not be appropriate to apply your programming principles. I find it very often that I have to refactor my code when applying programming principles to an old code base. Refactoring is always a risky thing to do, no matter how good your test code coverage is. Thus it is very important to asses how much risk involves to apply the principle. After we identify the magnitude of the risk, we need to asses how important is the build in which we need to patch. If it is a critical build, you might want to save your principle to be applied later on. For example, if you are making a build for deal that’s worth $500k+, introducing risk by refactoring a big chunk of your code, just to apply a programming principle, would be simply stupid. Apply your programming principles wherever and whenever it makes sense.
In this blog post, I’m taking a stand to neither sides. I agree completely with Uncle Bob in regards to code quality. Good programmer must have the craftsmanship passion to write the best code possible all the time. On the other hand, Jeff’s argument is also valid, because there are just times that might not be appropriate to apply programming principles.
Resources on the Uncle Bob vs Joel Spolsky:
RWendi
Remember Me
a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u