Page 183 - DCAP305_PRINCIPLES_OF_SOFTWARE_ENGINEERING
P. 183
Unit 9: Metrics
size of a module, from this metric the final size in LOC can be estimated. Alternatively, the size Notes
of each module can be estimated, then the total size of the system will be estimated as the sum
of all the estimates. As a module is a small, clearly specified programming unit, estimating the
size of a module is relatively easy.
9.1 Cyclomatic Complexity
Basis Pathway Testing: Basis path testing is a white box testing technique primary proposed by
Tom McCabe. The foundation path technique enables to derive a logical complexity measure of
a procedural design and use this measure as a guide for defining a basis set of execution paths.
Test Cases derived to exercise the basis set are guaranteed to execute every statement in the
program at least one time during testing.
Flow Graph Notation: The flow graph depicts logical control flow using a diagrammatic notation.
Each structured construct has a corresponding flow graph symbol.
Cyclomatic Complexity: Cyclomatic complexity is software metric that provides a quantitative
measure of the logical complexity of a program. When used in the context of a basis path testing
method, the value computed for Cyclomatic complexity defines the number for independent
paths in the basis set of a program and provides us an upper bound for the number of tests that
must be conducted to ensure that all statements have been executed at least once.
An independent path is any path through the program that introduces at least one new set of
processing statements or a new condition.
Computing Cyclomatic Complexity: Cyclomatic complexity has a foundation in graph theory
and provides us with extremely useful software metric. Complexity is computed in one of the
three ways:
1. The number of regions of the flow graph corresponds to the Cyclomatic complexity.
2. Cyclomatic complexity, V(G), for a flow graph, G is defined as V (G) = E-N+2P Where E,
is the number of flow graph edges, N is the number of flow graph nodes, P is independent
component.
3. Cyclomatic complexity, V (G) for a flow graph, G is also defined as V (G) = Pie+1 where
Pie is the number of predicate nodes contained in the flow graph G.
4. Graph Matrices: The procedure for deriving the flow graph and even determining a set of
basis paths is amenable to mechanization. To develop a software tool that assists in basis
path testing, a data structure, called a graph matrix can be quite useful.
A Graph Matrix is a square matrix whose size is equal to the number of nodes on the flow
graph. Each row and column corresponds to an identified node, and matrix entries correspond
to connections between nodes. The connection matrix can also be used to find the cyclomatic
complexity
Cyclomatic complexity measures the amount of decision logic in a single software module. It is
used for two related purposes in the structured testing methodology. First, it gives the number
of recommended tests for software. Second, it is used during all phases of the software lifecycle,
beginning with design, to keep software reliable, testable, and manageable. Cyclomatic complexity
is based entirely on the structure of software’s control flow.
LOVELY PROFESSIONAL UNIVERSITY 177