Blog.

What is code quality?

Quality code is the foundation of any software and is the basis of the quality of any product. But in reality, what are we talking about? What is the quality of code, and how do we measure it?

We can measure the quality of the code by using several metrics, but the most common ones are the following:

Coding standards

Coding standards are the set of rules that define the quality of a piece of code, and how it should be written. Although there are many coding standards, most of them are following the Clean Code principles from Robert C. Martin book (the book that we will come back on another post to vied those concepts with more detail). Of course not all coding standards are the same and do not always fit the team/project needs and goals, for that reason each one of them should be decided by the team and analyzed if it would add any value at all. In general, from my experience, I think that the most important thing to consider is the way the code is written, and the way it is written should be the same for all the team members keep in mind that the code should be written in a way that it is easy to read and understand for everyone.

Maintainability and Readability

One of the most significant situations to consider is the maintainability of the code and the ability to read it without too much effort. The maintainability of the code is the ability to change the code without breaking the code, and the ability to understand it with the minimum amount of support from the older team members or even someone that is not in the team anymore. In the current situation, we know that the engineers that wrote might not be around to fix the code, but we should still be able to understand the code and understand the problem that we are facing to fix it.

Keep that always in mind and leave the code as clean as possible, and try to make it as readable as possible using meaningful names and comments if you believe that would help the team to understand the code.

Peer review

One of the best ways to ensure that the code is readable and maintainable is to have a peer review process, where the team members review each other's code and make sure it follows the team best practices, and they can understand it. The code when it goes for peer review should closest to the final version as possible, we need to remember that the persons that would be reviewing the code it's spending valuable time and effort to understand the code, this is the reason we should enforce the lint rules and the team best practices to reduce the amount of time spent on peer review.

Code testing

There are several ways to test the code, and depending on the team and the project some might be more effective than others, but in general, we can rely on the following:

  • Unit testing: Unit testing is the process of testing the functionality of a single unit of code.
  • Integration testing: Integration testing is the process of testing the functionality of a system by combining the functionality of multiple units of code.
  • End-to-end testing: End-to-end testing is the process of testing the system following the flow of a user's interaction with the system and the expected results.
  • Smoke testing: Smoke testing is the process of testing in an environment as close to the production environment as possible without mocking any external dependencies.
  • Accessibility testing: Accessibility testing is the process of testing for accessibility issues in a web application ensuring that the application is usable by all users, offering a more inclusive web as it should be.

This is too much of a wither topic to discuss here, but I will try to explain the different ways to test the code and how to do it on a real project in a later post.