Information Technology Reference
In-Depth Information
FIGURE 17.1
A control flow graph.
where, if a flow graph is provided, the nodes represent program segments and edges
represent independent paths. In this situation, e is the number of edges, n is the number
of nodes, and C is the conditional complexity. Using this equation, a conditional
complexity with a higher number is more complex.
In Figure 17.1, the program begins at the red node and enters the loop with three
nodes grouped immediately below the red node. There is a conditional statement
located at the group below the loop, and the program exits at the blue node. For this
graph, e
1, so the complexity of the program is 3. 7
It often is desirable to limit the complexity. This is because complex modules are
more error prone, harder to understand, harder to test, and harder to modify (McCabe,
1996). Limiting the complexity may help avoid some issues are associated with high-
complexity software. It should be noted that many organizations successfully have
implemented complexity limits, but the precise number to use as a limit remains up
in the air. The original limit is 10 and was proposed by McCabe himself. This limit
of 10 has significant supporting evidence; however, limits as high as 15 have been
used as well.
Limits greater than 10 typically are used for projects that have several operational
advantages over typical projects, for example, experienced staff, formal design, a
modern programming language, structured programming, code walkthroughs, and a
comprehensive test plan. This means that an organization can select a complexity
limit greater than 10 but only if the organization has the resources. Specially, if a
limit greater than 120 is used, then the organization should be willing to devote the
additional testing effort required by more complex modules. There are exceptions to
=
=
=
9, n
8, and P
7 http://en.wikipedia.org/wiki/Cyclomatic complexity
Search WWH ::




Custom Search