Measuring code quality

This article is part of our code quality metrics series.

1 - Measuring Code Quality 

2 - The consequences of poor code quality 

3 - How to measure code quality

4 - What are good code quality metrics? 

5 - Tools to measure code quality 

This is all for you to have the whole 360 understanding around this topic. 

As software engineers we each have a responsibility ensuring the quality of the software we produce. And as scientific animals the one thing we rely on to appreciate quality is measuring. Metrics are the key to a successful code quality strategy: they give us clear targets, they engage all members of the team in the success of a project and they demonstrate to higher management that sustainable and industrial grade quality code manufacturing can be achieved. But the devil is in the details! Metrics can create unbalance and corrupt your project if they are not wisely orchestrated.

As an industry we have a responsibility to do better and reach the same level of efficiency that some mature industries have achieved to get to. This can not be achieved without the right set of metrics and we wanted to provide you with a conversation starter to educate yourself and help you challenge the status quo of your code quality strategy.

USD 85,000,000 is the amount of money lost into bad code in 2018 (i.e. code defects maintenance, bugs and regressions) Stripe & Harris. The Developer Coefficient. A figure so high it seems beyond control and which certainly has not diminished since the beginning of the pandemic. As the software industry grows at its fastest pace ever and as companies’ respective software assets are growing we are all struggling with a new challenge: how can we scale up software manufacturing while stabilizing or reducing the technical debt we create. The industry comes to the realization that actions need to be taken today and some stakeholders are stirring things thanks to powerful QA automation processes and shift left advocacy.

Within the challenge of defining and executing industrial grade quality your company just like any other needs to gather their tech and non tech team members around the table. You need to set the appropriate code quality goals and in order to do that you need to work out an adequate way to monitor quality that enables everybody around the table to speak the same language.

Shifting from a craftsmanship-focused approach of coding toward an industrial production line approach implies that you invest the means to have a homogeneous understanding of what true code quality is.

With this blog post series we want to take tech and non tech leaders and managers on a journey to question and uncover what is the definition of code quality and how it should be monitored in order to enable innovation at scale. This series is meant to educate on the topic of code quality through the review of different metrics used in the industry and their limitations. A document designed as a conversation starter for you and your team to challenge how code quality is achieved in your company and how you can reach industrial grade quality that does not get in the way of your delivery speed.

What are the characteristics of code quality ?

Code quality achieves, in a very contradictory way, to both be a highly discussed and debated topic while being the most undervalued aspect of software development. The not-so-young-anymore software industry has seen its technology, its processes and its practice evolve at an exponentially fast pace since the 80s. Fast enough that quality was put aside in the name of efficiency. Behind the curtain though, since the very creation of software development, many scientists and engineers have bravely tried to face the challenge of putting one definition of code quality that would include the diversity of languages, frameworks, projects and the deep complexity of modern code architecture.

One of the first, if not the simplest approach to assess code quality was to just control that the software fulfills its purpose. But this very quickly felt incomplete and all stakeholders agreed to say that code quality was three dimensional. Good code quality implies the readability of code for the sake of collaboration, the efficiency of the software for the sake of the user experience and the stability of the software for the sake of business continuity. Since then numerous objective definitions have appeared, often questioned as the processes, languages and tools evolved.

As the industry is seeking an objective and global definition it has become commonly recognized in the now half a decade old IT industry that code quality falls under 5 criterias: efficiency, refactorization, test, documentation and security.

Achieving the right level for each of these criterias, and monitoring their evolution over time can prove challenging. Above all because the set standards are subject to different interpretations and it’s still common that the set targets rely on the project and the team who have authority to set them. Consequently they widely differ across projects and teams. What is considered as the right level fluctuates because the industry has not set an industrial and universal standard recognized as “the bare minimum'' to achieve.

Some might make the mistake of driving all business decisions based on their impact over short term revenue generation. Consequently they would only look at the current good behavior of the application. Unlike car manufacturing, some are still satisfied with software release if the code computes on day 1 and will not take longevity into consideration. Ignoring the criticality of test exhaustiveness, quality of documentation, style of code, securing and refactoring would be a mistake with heavy short, middle and long term consequences for your profitability.

Consequently tech or non tech leaders have to find their own way to define quality for their projects and set the range of metrics that will enable all stakeholders to be incentivized with clear and legitimate objectives upon creation and maintenance of code. 

Code quality dimensions

Given the significance of code quality, the need for monitoring and measurement seems self-evident. In a data-driven approach, you'll need a set of metrics to provide clear goals and bring all project stakeholders together to agree on the standard of acceptable quality. Metrics are a tool for motivating, communicating, and establishing boundaries. Let’s move on to the second part of our code quality metric series and discover how code quality impacts your business metrics. 

Or you can jump straight into the other articles:

References 

The Developer Coefficient-Stripe Harris

Métriques et critères d'évaluation de la qualité du code source d’unlogiciel-PierreMengal

Iso25000.com

Comparison of the SIG Maintainability Model and the Maintainability Index - Frank R. Oppedijk

Sustainable software development

2018 Google Adwords Survey France

Also on the hub

Ready to write beautiful code?

Smart and simple unit testing assistant. Now available for free.

Try it now

Solutions for JS, TS, Java and Python

Lines Footer
Flexing Unicorn by Ponicode