Information Technology Reference
In-Depth Information
the complexity limit as well. McCabe originally recommended exempting modules
including single multiway decision statements from the complexity limit.
Cyclomatic complexity has its own drawbacks as well. One drawback is that it
only measures complexity as a function of control flow. However, complexity also can
exist internally in the way that a programming language is used. Halstead's metrics
are suitable for measuring how intensely the programming language is used.
Halstead's Metric 8
17.2.4
The Halstead metric bases its approach on the mathematical relationships among
the number of variables, the complexity of the code, and the type of programming
language statements. The Halstead metric has been criticized for its difficult com-
putations as well as its questionable methodology for obtaining some mathematical
relationships. 9
Some of Halstead's metrics can be computed using Section 5.3.2. Another metric
is the amount of mental effort used to develop the code, which is E and is defined
as E
V / L . Decreasing the effort will increase the reliability and implementation
(LaPlante, 2005).
=
17.2.5
Cohesion
Cohesion is the measure of the extent to which related aspects of a system are kept
together in the same module and unrelated aspects are kept out. 10 High cohesion
implies that each module represents a single part of the problem solution; thus,
if the system ever needs to be modified, then the part that needs to be modified
exists in a single place, making it easier to change (LaPlante, 2002). In contrast,
low cohesion typically means that the software is difficult to maintain, test, reuse,
and understand. Coupling, which is discussed in greater detail in the next section, is
related to cohesion. Specifically, a low coupling and a high cohesion are desired in a
system and not a high coupling and a low cohesion.
LaPlante has identified seven levels of cohesion, and they are listed in order of
strength:
1. Coincidental—parts of the module are not related but are bundled in the module
2. Logical—parts that perform similar tasks are put together in a module
3. Temporal—tasks that execute within the same time span are brought together
4. Procedural—the elements of a module make up a single control sequence
5. Communicational—all elements of a module act on the same area of a data
structure
8 See Chapter 5.
9 http://cispom.boisestate.edu/cis320emaxson/metrics.htm
10 http://www.site.uottawa.ca:4321/oose/index.html#cohesion
Search WWH ::




Custom Search