Code quality is usually underrated in some organisations because it is an aspect that customers don’t see and don’t pay for. However it is quite important in both the short and long term. I will expose some of the reasons.
Allows to develop faster
Developers can work faster when the code is clean and easy to read, and in case of doubt they can look to the tests to see how the main code should be used. They are also more confident about doing changes when there are tests because they have a safety net that will detect if they break anything.
It is already documented
People think about documentation as writing long texts in wikis or docs. However the best way to document code is using proper method and variable names and adding tests that explain what the code does in a format such as “given an scenario when this happens the system should behave that way”. That way the code is self documented and it is much better that adding comments or documents that nobody read and that soon get update.
It sets the bar for new code
In 1982 two researchers proposed the broken window theory. They observed that gangs in New York respected the houses that looked cleaned but vandalised the ones that looked abandoned.
The same happens with the code. When people start cooperating in a project and they see that it has good code and is tested, they force themselves to maintain the same level. However they may not do the same in other projects that have bad code and no tests. Also, when a project is in a good shape, the owners find it easier to force new contributors to do the right things because that is the standard of quality of the team.
New code without tests is already legacy
People usually talk about old unmaintainable code as legacy. However, every time that a new line is added without tests it becomes legacy too as only the person that wrote it knows the impact of changing it.
Lack of time is not a excuse
We all know how tight can be the deadlines when we work for startups. We have to be all the time delivering features faster than competitors so we can get customers that allow the company to survive a few more months. However there are also some calm periods when we can go back and improve the testing coverage and those parts that are not as good as they could be.
I have highlighted some of the reasons of why it is important to have good quality since the beginning. How is in your team? Do you do an effort to keep it clean and tested, or the fast pace of work doesn’t allow you to do it? As always I would love to read your opinions in the comments below.