|Prev - Next - Down||SDMetrics - the UML design measurement tool|
The nesting procedure has one required attribute, relation, specifying the relation which establishes the nesting relationship. Usually, this will be the "context" relation. For example:
<metric name="NestingLevel" domain="package"> <nesting relation="context" /> </metric>The calculation procedure is as follows: retrieve the element that is referenced by the specified relation (here: context). If this element is "compatible", recursively calculate the metric for that element, increase by one, and return that value. Else (context element is not of the same type, e.g., top level packages defined in the namespace of the model), the metric yields 0.
An element is "compatible" with nesting metric m of domain type t if the type of the element is t, or if its type is a subtype or supertype of t and metric m is defined for the type.
For a typical package hierarchy, the results are (column NestingLevel):
How does the nesting procedure is differ from projections using the nesting attribute? Projections navigate the specified relation in the opposite direction. A projection operates on all elements where the specified relation points to the current element for which the projection is calculated (navigation to the current element). The nesting procedure, on the other hand, simply navigates from the current element to the element referenced by the specified relation (navigation away from the current element). Consequently, a metric LNest defined as a projection as follows would count the levels of nesting within a package (as shown in column "LNest" of Table 5):
<metric name="LNest" domain="package"> <description>Levels of package nesting in this package.</description> <projection relation="context" target="package" nesting="true" /> </metric>
|Section 8.1.3 "Attribute Value"||Contents||Section 8.1.5 "Signature"|