O'Reilly logo

Making Software by Greg Wilson, Andy Oram

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required