Maintainability Index Revisited
Maintainability Index Revisited
Maintainability Index Revisited
MAINTAINABILITY INDEX
The MI is a composite number, based on several unrelated
metrics for a software system. It is based on the Halstead
Volume (HV) metric [2], the Cyclomatic Complexity (CC) [3]
metric, the average number of lines of code per module
(LOC), and optionally the percentage of comment lines per
module (COM). Halstead Volume, in turn, is a composite
metric based on the number of (distinct) operators and
operands in source code. The complete fitting function is 171 5.2 * ln(HV) - 0.23 * CC - 16.2 * ln (LOC) + 50 * sin
(sqrt(2.4 * COM)). The higher the MI, the more maintainable
a system is deemed to be.
Root-cause analysis
Since the MI is a composite number, it is very hard to
determine what causes a particular value for the MI. The
acceptance of a numerical metric with practitioners, we find,
increases greatly when they can determine what change in a
system caused a change in the metric. When the MI has a
particularly low value, it is not immediately clear how to
increase it.
Average complexity
One of the metrics used to compose the MI is the average
Cyclomatic Complexity. We feel this is a fundamentally
flawed number. Particularly for systems built using OO
technology, the complexity per module will follow a power
law distribution. The average complexity will invariably be
low (e.g. because all setters and getters of a Java system have
a complexity of 1), whereas anecdotal evidence suggests that
the maintenance problems will occur in the few outliers that
have a complexity of over 100.
Computability
Particularly the Halstead Volume metric is difficult to
compute. There is no formal definition of what constitutes an
operator or an operand in a language such as Java or C# [4].
Halstead Volume is a metric that is not widely accepted within
the software engineering community. See [5] for a critique.
Comment
The implication of using the number of lines of comment
as a metric is that a well documented piece of code is better
to maintain than a piece of code that is not documented at all.
Although this appears to be a logical notion, we find that
counting the number of lines of comment, in general, has no
relation with maintainability whatsoever. More often than not,
comment is simply code that has been commented out, and
even if it is natural language text it sometimes refers to earlier
versions of the code. Apparently, the authors of the MI had
reservations about measuring comment, as they made this part
of the MI optional.
Understandability
Number of units
[2]
[3]
[4]
Szulewski, Paul, et al. Automating Software Design Metrics (RADC-TR84-27). Rome, NY: Rome Air Development Center, 1984.
[5]
[6]
Baxter, I. D., Yahin, A., Moura, L., Sant'Anna, M., and Bier, L. 1998.
Clone Detection Using Abstract Syntax Trees. In Proceedings of the
international Conference on Software Maintenance (March 16 - 19,
1998). ICSM. IEEE Computer Society, Washington, DC, 368.
[7]