Online Eiffel Documentation
EiffelStudio

Units

Metrics will be expressed in units, such as Line (numbers of source lines) or Feature (number of features).

Unit rule: The definition of any metric must specify an associated unit.

Different metrics may be marked with the same unit; for example metrics such as number of non-comment lines and number of comment lines may both be marked with the unit Line.

Whenever we need to express ratios of one measurement to another, as in computing the average number of features per class by dividing the number of features by the number of classes, we will use a specific unit, Ratio:

"Ratio unit": The name Ratio denotes a predefined unit, whose values are arbitrary real numbers, expressed either as numbers or in percentage style (as in 35.3%).

As a result of this choice, we will consider every division to yield a result of unit, Ratio.

The following predefined units are available in the metric tool:

UnitQuantities measuredKind
ClassNumber of classes or types Product
GenericNumber of class generics Product
FeatureNumber of features Product
TargetNumber of targetsProduct
GroupNumber of groupsProduct
AssertionNumber of assertion clausesProduct
ArgumentNumber of arguments of a routineProduct
LocalNumber of locals of a routineProduct
LineNumber of source lines Product
CompilationNumber of compilations Process
RatioResults of divisions Product

The units listed here are minimal in the sense that it is not possible to add the properties measured by any two of them; for example it makes no sense to add a number of features to a number of classes.

In the future, it might be desirable to include more specific units, such as "features per class" , and an associated calculus of units (as in the physical sciences, where multiplying a quantity expressed in g /cm by one in cm yields a result in g). This has not appeared necessary for the typical uses of division envisioned in this note, answering such questions as "What percentage of routines have a header comment" can all be expressed simply as ratio.

Code Element

For most of units, an item of that unit represents a code element in a real system. For example, an item of class unit represents a class and an item of line unit represents a line of code. All supported code elements are listed as follows:

Code ElementUnitDescription
ClassClassRepresents a class
GenericGenericRepresents the piece of the code related to generics definition in a class definition.
FeatureFeatureA feature or an invariant clause. In metrics tool, a feature can be one of two things: a traditional feature, or an invariant clause. That is to say, an invariant clause is treated as a special feature. To avoid ambiguity, we call a traditional feature a "feature" and an invariant clause an "invariant feature".
TargetTargetRepresents a target
GroupGroupRepresents a group in system. A group can be either a cluster, a library or an assembly
AssertionAssertionRepresents an assertion
ArgumentArgumentRepresents a formal argument in features
LocalLocalRepresents a local defined in features
LineLineRepresents a line of code
Folder-Represents a physical concept to store classes. The semantic of a folder in metrics tool is equal to a list all classes which are located in that folder (not recursively). So a folder item doesn't provide new functionality, it just facilitates the operation to select a set of classes.
Delayed item-A delayed item is a place holder, it will be replaced by the candidate code element over which a domain criterion is evaluated
Input domain item- An input domain item is a place holder, it will be replaced by the domain selected as input to the metric. In the case that the input domain is presents in a basic metric definition, when that metric is calculated, the metric will use the current application target as the input domain.
Current application itemTargetRepresents the application target of the current Eiffel system