Information Technology Reference
In-Depth Information
where
is the number of decision points in the program and s is the number of exit
points.
This metric is an indication of the number of “linear” segments in a software system
(i.e., sections of code with no branches) and, therefore, can be used to determine the
number of tests required to obtain complete coverage. It also can be used to indicate
the psychological complexity of software.
A code with no branches has a cyclomatic complexity of 1 because there is 1 arc.
This number is incremented whenever a branch is encountered. In this implementa-
tion, statements that represent branching are defined as follows: “for”, “while”, “do”,
“if”, “case” (optional), “catch” (optional), and the ternary operator (optional). The
sum of cyclomatic complexities for software in local classes also is included in the
total for a software system. Cyclomatic complexity is a procedural rather than an
object-oriented metric. However, it still has meaning for object-oriented programs at
the software level.
McCabe found that C
10 is an acceptable threshold value when he analyzed 10
modules and modules with C
=
>
10 had many maintenance difficulties and histories
of error.
A popular use of the McCabe metric is for testing. McCabe himself cited software
testing as a primary use for his metric. The cyclomatic complexity of code gives a
lower limit for the number of test cases required for code coverage.
Other McCabe Complexity Metrics 2 :
Actual Complexity Metric: The number of independent paths traversed during
testing.
Module Design Complexity Metric: The complexity of the design-reduced mod-
ule. Reflects the complexity of the module's calling patterns to its immediate
subordinate modules. This metric differentiates between modules that will seri-
ously complicate the design of any program they are part of and modules that
simply contain complex computational logic. It is the basis on which program
design and integration complexities are calculated.
Essential Complexity Metric: A measure of the degree to which a module con-
tains unstructured constructs. This metric measures the degree of structuredness
and the quality of the code. It is used to predict the maintenance effort and to
help in the modularization process.
Pathological Complexity Metric: A measure of the degree to which a module
contains extremely unstructured constructs.
Design Complexity Metric: Measures the amount of interaction between mod-
ules in a system.
Integration Complexity Metric: Measures the amount of integration testing nec-
essary to guard against errors.
Object Integration Complexity Metric: Quantifies the number of tests necessary
to fully integrate an object or class into an object-oriented system.
2 http://www.mccabe.com/iq research metrics.htm.
 
Search WWH ::




Custom Search