- 17.05 (released) ...
Raw metrics and selection criteria
Elementary metrics measure patterns whose occurrences (in a product or process) can be counted. We need to decompose this notion further to avoid an explosion of the number of elementary metrics. For example the features of a class can be classified along several lines:
- Some are attributes (object fields), others are routines (algorithms).
- Some are inherited from a parent, others immediate (defined in the class).
- Some are exported, others secret
and so on. Many combinations of these properties may be worth counting on their own: you may ask for the number of secret attributes, of exported inherited features and so on. But if we define all of these metrics independently, we will soon have too many elementary metrics, while still failing to satisfy user needs if we have omitted a particular combination.
To avoid this we must identify a subset of elementary metrics as raw metrics: metrics whose results are counted directly. "Number of features in a class" is a raw metric. From a raw metric, we may then derive other elementary metrics by applying selection criteria such as "Is this feature an attribute?" or "Is this feature exported?" Here are the definitions:
A set of raw metrics and selection criteria is provided by default by the metric tool, see predefined raw metrics and selection criteria
To define a derived metric, we start from a raw metric, for example "number of features", and combine some of the associated selection criteria. The combination may be:
- An "or": for example, count all the features that are attributes or exported (or both).
- An "and": count all the features that are both attributes and exported.
A selection criterion may have more than two possible values. Most, as in these examples, have just two: a feature is either an attribute or a routine; it is either exported or secret.
The definition states that every derived metric is derived from a certain raw metric or from another derived metric.
As a general guideline, we will try to keep the selection criteria for a given raw metric independent. For example, to distinguish the classes that inherit a given class we will use the following selection criteria:
- Heirs: count the number of direct heirs of a class.
- Indirect_heirs: count the number of indirect heirs.
- Self: count only the class itself.
Other interesting notions are "proper descendant", covering direct and indirect heirs, and "descendant", covering proper descendants and descendants. We do not introduce these as separate criteria, since this would result in a non-independent set of criteria: every proper descendant is a descendant, every heir (direct or indirect) is a proper descendant.
Instead we limit ourselves to the three criteria listed above. If you need a finer decomposition, it is easy, with the techniques discussed below, to define Proper_descendants and Descendants as composite metrics expressed in terms of the elementary metrics Heirs, Indirect_heirs and Self.
This criterion independence principle is not absolute, however, and in some cases we may find it clearer to define a new criterion even though its value is entirely determined by certain values of another. For example one criterion on features determines whether it is an attribute or a routine, another whether it is deferred or effective. An attribute is always effective, so the two criteria are not independent. Even though we could remove the dependency by using a single criterion with three values (attribute, effective routine, deferred routine), it is more convenient to keep two criteria. Of course the underlying counting mechanisms must make sure never to count an element twice even in an "or" query, as when a user asks for the number of features that are attributes or effective.
A metric is either elementary or composite. An elementary metric is either a raw metric, such as "number of features", or a derived metric obtained from slicing a raw metric by selection criteria. Composite metrics are obtained from existing metrics (elementary, or previously defined composite metrics) by applying some mathematical formula.