|Prev - Next - Down||SDMetrics - the UML design measurement tool|
An identifier is a letter or underscore (a-z, A-Z, _), followed by any sequence of digits (0-9), letters, and underscores. Examples of valid identifiers are: i, visibility, NumOps, set2, Metric1_a, _principal.
By convention, attribute names start with a lowercase letter, metric and set names with an uppercase letter, and variables with an underscore. This avoids name conflicts between metrics or sets, attributes, and variables.
VariablesMetric, set, and rule procedures can define variables that hold values with special meanings for the calculation. We access those values in metric, set, and condition expressions. SDMetrics defines two standard variables _self and _principal.
The variable _self yields the model element for which the expression is evaluated. The variable _principal yields the model element for which the current metric, set, or rule is evaluated. Variables _principal and _self need not be the same element. In fact, the variable _principal should only be used if it is not the same element as _self.
Consider the following example. The metric counts, for a class A the supplier classes on which A depends that have more operations than A:
<metric name="SuppliersWithMoreOperations" domain="class"> <description>The number of classes this class depends on that have more operations.</description> <projection relation="depclient" target="dependency" element="depsupplier" eltype="class" condition="_self.NumOps > _principal.NumOps"/> </metric>The condition expression is evaluated, in turn, for each supplier class of class A. The variable _self therefore refers to the supplier class. The variable _principal always refers to class A for which the metric is calculated.
Note: the condition expression in the above example could have also been written as "NumOps > _principal.NumOps", because the identifier NumOps will be interpreted as a metric of the model element for which the expression is calculated. In fact, variable _self is rarely needed in practice. Useful applications include
|Section 220.127.116.11 "Constants"||Contents||Section 8.5.2 "Metric Expressions"|