Clean code gets a bad reputation sometimes.
Provide some code improvement tips to a developer, and they might respond with…
But my code works! I like how it looks, go away.
— Your favorite developer
Or perhaps you suggest some extra time be factored into a project to clean up the code, and your PM responds with…
I don’t think we have time at this moment, let’s deliver what was asked.
— Your favorite project manager
With such common opposition, why do I still care so much about code quality?
Writing code is an investment, especially in most cases where it has to be later maintained or have new features added.
Invest in quality code, and you will reap a valuable return: less issues and quick turnarounds on bugfixes and new features.
From both a business and developer aspect, this seems highly beneficial right? I would say so, and that is why I strongly believe that code quality is something many companies should invest in.
Clean code is subjective, so if you haven’t noticed I prefer the term quality code.
Foremost, quality code is working code. This means that the examples I used in the beginning are 100% correct: delivering working code is most important.
The problem is that many simply stop right there. The next step is to ensure that code continues to work, and you do that by writing tested code. With proper integration and unit tests, you gain confidence in knowing how your code works and what changes may cause it to break.
Finally, helping with maintenance is consistent code. There are tools that can help out in this regard as well such as ESLint and Prettier, but there are many architectural decisions that will have to be agreed upon and well documented for future maintainers to learn from. Delegating as many of those decisions and enforcements to tools will help prevent future disagreements or developers that want to do it “their own way”.
If it’s even possible to shamelessly plug within my own newsletter, I wrote a very relevant article titled Writing code for your future self.
If you’re a developer in any size company where code quality is not seen as important, you can be the one to change that. Start by setting an example, and slowly suggest the value that automating or enforcing some of these tasks can provide.
<meta>
tags.See you next Sunday, same inbox? 👋