A Sample Measurement

Table 8-1 contains a summary of all the metrics used in this study, and the symbols denoting these metrics in the rest of the tables and figures.

Table 8-1. Selected metrics for the study

VariableMetric (symbol)
SizeSource Lines of Code (SLOC), Lines of Code (LOC)
 Number of C functions (FUNC)
ComplexityMcCabe’s cyclomatic complexity—maximum of all functions (MCYCLO)
 McCabe’s cyclomatic complexity—average (ACYCLO)
 Halstead’s length (HLENG), volume (HVOLUM), level (HLEVE), and mental discriminations (HMD)

The elements of code that provide input to all these metrics are illustrated in the sample source code file shown in Example 8-2. This file was extracted from the package urlgfe, a cross-platform download manager. (urlgfe has recently changed its name to uget, so it is no longer found in the ArchLinux repositories with its original name.) The file contains preprocessor directives (such as 1), comments (such as 3), and only one function (starting at line 4) containing a while loop.

Example 8-2. A sample C source code file

#ifdef HAVE_CONFIG_H 1
# include <config.h>
#endif
 /* Specification. ...

Get Making Software now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.