Does Code Quality Matter?
Tags: webdev, productivity, computerscience
Published: 2020-03-06 16:58:14

Does code quality matter? How much does it matter? In your day-to-day coding, how much time and energy should you spend worrying about code quality?

To begin with, what exactly is code quality? On this matter, there is definitely a host of both vague and well-defined criteria for what code quality exactly is. There are machine calculable criteria, such as [cyclomatic complexity](https://en.wikipedia.org/wiki/Cyclomatic_complexity) and similar measures, as well as more subjective measures. I believe though, that the idea of code quality can be adequately condensed down to one succinct point: Code readability. The entire point of code quality is for readability. This is the result we're seeking when we worry about and work to improve the quality of our code. We're trying to increase its readability. So quality code is readable code and vice versa.

Now that we know what it is, we can return to our original question. Does code quality help? Does it matter?

The very definition we came up with helps us begin to answer that question: readability. What is the benefit of readable code? Readability allows us to more effectively create mental models of the code we're reading. It's these mental models we have that allow us to write/modify our code. We must have a mental model (accurate or not) in order to write code. Without a mental model, we can only make random changes, like a chimp on a typewriter.

So where do our mental models come from? Here, there are two distinct answers. When first writing code, the mental model starts in our head and is then put into code. But when maintaining and modifying code written by others, or by us some time ago (possibly last year, possibly this morning), then the flow is that we must read the code, then create our mental model, and then we can change the code.

So code quality (readability) becomes very important as we do the second activity of reading code to modify it.

How much time do we really spend reading code then? "Indeed, the ratio of time spent reading versus writing is well over 10 to 1. We are constantly reading old code as part of the effort to write new code. …[Therefore,] making it easy to read makes it easier to write." ― [Robert C. Martin](https://www.amazon.com/dp/0132350882/ref=cm_sw_r_tw_dp_U_x_Awc7CbG7HBT0H).

Ten to One! Suddenly code quality emerges as a critical concern. Unfortunately, I believe in most cases, code quality is the third priority as we develop, falling after correctness and then time constraints/deadlines.

Code quality can, therefore, be seen as a very important concern. Something that does matter a great deal. I personally built a great deal of my career upon code quality, which is not to say that I believe that I am particularly good at writing highly readable code, only that I truly care about the practice and that I constantly seek to improve at this skill.

If quality isn't a very big concern of yours in your current job, I encourage you to rethink this and make changes to increase its priority in the code you write. In the future, I'll talk about ways to improve your code quality, but for now, leave with this simple encouragement: code quality matters! Don't leave it behind in the race to meet your deadlines.

Happy Coding!

Enjoy this discussion? Sign up for our newsletter [here](https://thinkster.io/?previewmodal=signup?utm_source=devto&utm_medium=blog&utm_term=codequality&utm_content=&utm_campaign=blog).

Visit Us: [thinkster.io](https://thinkster.io?utm_source=devto&utm_medium=blog&utm_term=codequality&utm_content=&utm_campaign=blog) | Facebook: @gothinkster | Twitter: @GoThinkster