
bounce = (balance < withdrawal)? true : false;
Fig. 2. Code sample 2
If we count physical lines of source code, as recommended by [4], the first sample
contains six lines of code, whereas the second contains only one. Using these values,
one might conclude that the first sample accomplished more or was more complex,
when in reality they both accomplish the same task. Moreover, the first code sample
is easier for a non-C++ expert to understand, so it may be easier to maintain.
In contrast, semantic metrics are concerned only with the ideas involved. In this
example, semantic metrics would pick out the concepts of balance, withdrawal, and
bounce in the banking domain, without regard to the way the code was written. Thus
differences in programmer style and even programming language used will not impact
semantic measures of the system’s size or complexity.
Furthermore, because semantic metrics do not depend on the structure of the code,
they can be calculated from requirements and design documents before the code has
been written [2]. This allows quality to be assessed earlier in the development
process, when changes are cheaper to make.
2 Validating Metrics
Kitchenham, Pfleeger, and Fenton [5] proposed a framework for validating
measurements of software. First, they identified necessary concepts for measurement:
• Entities – things we want to know more about
• Attributes – properties we want to measure
• Units – mapping between an attribute and number system (ex. inches)
• Scale types – nominal, ordinal, interval, or ratio
Thus, a metric value should measure an attribute of an entity using some unit.
Units are valid for ratio and interval data and can be adapted to work with ordinal data
[5].
The four aspects of validity for a measure are:
• Attribute validity: the entity being studied has the attribute.
• Unit validity: the unit used is appropriate for the attribute.
• Instrumental validity: the underlying model is valid and the measurement
instrument is calibrated.
• Protocol validity: the measurement is taken in a way that is consistent,
unambiguous, and prevents problems such as double counting [5].
Generally, there are direct measures and indirect measures. For direct measures,
the following theoretical properties should apply:
• There exist at least two different entities that have different values for the attribute.
• The measurement must work in a way that makes sense with respect to human
understanding of the attribute.
• If the attribute is part of a valid measurement, any of its units can be used.
50