Making Good Software

A blog by Alberto G (Alberto Gutierrez)

Written by Alberto Gutierrez

May 7th, 2009 at 5:00 pm

The pyramid of code quality, the 5 characteristics of good code.

with 18 comments

The quality of the code can be seen as pyramid where each of the 5 vertex are one characteristic of the code.

The pyramid has two parts the base, and the apex.

pyramid

The base of the pyramid will be formed by the characteristics that make the code robust, future-proof. The apex is represented by the amount of functionality and reliability of the code.

The higher you want your apex to be (more functionality and reliability) the bigger the base has to be.

The base of the pyramid

pyramid_basenames

Readability

This characteristic measures how easy is to read and understand the code and it’s purpose. The main factors that affect the readability are:

  • Good comments
  • Good naming of variables, functions, classes…
  • Consistent coding standards
  • Clean logic

The highest readability, the less time a new developer will need to understand what the current code is doing.

Extensibility

This characteristic measures how easy is to add new functionality, a good design will likely provide high extensibility. The highest extensibility, the less time for a developer to add new functionality as changes in the current code shouldn’t be necessary.

Atomicity

This characteristic measures how the different units of logic of the application are separated so that when a change is necessary it is only performed in one place in the current code. High atomicity is usually achieved following a few good principles when coding like:

  • SOLID Principles
  • DRY
  • Continuous refactoring

Testability

This characteristic measures how much automated and how much coverage the code tests have. This not only covers unit testing, but integration testing and E2E testing as well.

The apex of the pyramid

The apex of the pyramid measures how many things the code does, and how reliable it is.

Balancing the base and the apex.

The key for having a good pyramid is that the base is big enough for the required apex, in the next post we will discuss what different types of pyramid shapes we can find and which are adequate for every scenario, you can subscribe to get the second part of this article by following the RSS link on the top right hand side of the blog.