“You cannot control what you cannot measure.”
(by Tom De Marco)
“Measurement” is a fundamental activity to any engineering discipline. Measuring and quantifying aspects associated with a system of interest help us understand the characteristics of the system and pave the way to derive interpretations and insights about the system.
In the context of software systems, there are numerous kinds of metrics associated with different aspects of software and software development such as product or process metrics where product metrics can be further classified as static and dynamic metrics and even further such as code, requirement, or test metrics. A software metric is a measure of some property of a software system.
This post focuses on static code and design metrics to reveal the structural health of a software system and discusses different metric types, their meaning and interpretations as well as a few tools that could be helpful identifying such metrics.
Table-1 summarizes metrics commonly used to analyze maintainability of a software system. These metrics can be classified in three broad categories viz. size, complexity, and cohesion and coupling. Let us take a deeper look at these metrics.
Table 1: Software Metrics and their categories
1. Size Metrics
Each software entity must be of moderate size. Large entities are difficult to understand, use, reuse, and test. Often, large entities implement more than one responsibility and violate Single Responsibility Principle (SRP). Table-2 shows description and typical threshold used for each metric concerning size.
Table 2: Size metrics with description and typical threshold
| Metric | Description | Threshold |
| LOC | Lines Of Code – Total lines of code in a source-code entity | Method – 80, Type - 1000 |
| NOM | Number Of Methods – Total number of methods in a type | 30 |
| NOF | Number Of Fields – Total number of fields in a type | 20 |
| DIT | Depth of Inheritance Tree – Maximum length of the path from this type to root of the inheritance tree | 6 |
| NC | Number of Children – Total number of sub-classes of a type | 10 |
| NOC | Number Of Classes – Total number of types in a namespace | 20 |
| NON | Number of Namespaces – Total number of namespaces in a project | 5 |
| NP | Number of Parameters – Total number of parameters in a method | 6 |
A note about thresholds – The thresholds presented in the above table (and throughout this article) are indicative and may change based on organization or project code quality guidelines.
2. Complexity Metrics
Cyclomatic Complexity (CC) is a commonly used metric to measure the complexity of a method. It indicates a total number of possible unique paths from the beginning of a method to exit the method. It is considered crucial since a high value of CC in a method indicates high number of tests required to cover all the paths in the method (In fact, minimum number of tests must be written for the method is equal to CC). Weighted Methods per Class (WMC) is the sum of cyclomatic complexities of all the methods belonging to the class. Table-3 lists the complexity metrics with description and associated thresholds.
Table 3: Complexity metrics with description and associated typical threshold


Anish AnsariPosted Nov 12, 2015, 8:43 AM
Nice Article
Mohamed Gani MnPosted Nov 6, 2015, 8:30 AM
Much Better Article
Rohit TiwariPosted Nov 5, 2015, 11:41 PM
very good article sir, nice share
Sibeesh VenuPosted Nov 5, 2015, 7:58 AM
Nice Share
Gopi ChandPosted Nov 5, 2015, 6:01 AM
Interesting...
Humayun Kabir MamunPosted Nov 5, 2015, 1:39 AM
Nice...