| Prev - Next - Down | SDMetrics - the UML design measurement tool |

Figure 34: Example dependency links
Class c is the client in three dependency relationships with three suppliers: a package and two classes. A dependency element links the client and supplier via its cross-reference attributes "depclient" and "depsupplier" (cf. metamodel element dependency in the appendix). We can specify a projection for the "depclient" relation for dependency elements:
<metric name="Dependencies" domain="class"> <description>The number of dependencies in which the class participates as client.</description> <projection relation="depclient" target="dependency" /> </metric>This projection retrieves the elements of type "dependency" where the given class is the client. For class c, this would get us d0, d1, and d2. So far so good, however, we may not want to access the dependency elements, but the actual suppliers themselves, e.g., to filter for suppliers of a certain element type.
<metric name="SupplierElements" domain="class">
<description>The supplier elements of which the class
is a client.</description>
<projection relation="depclient" target="dependency"
element="depsupplier" />
</metric>
By specifying the attribute "element", the projection does not access
the dependency element, but the element referenced via the
"depsupplier" relation specified by the "element" attribute. In
Figure 34 above, this would give us p, s1, and s2. In other
words, the supplier we want. To filter for suppliers of a certain
type, we specify the additional attribute "eltype" that indicates the
type of elements we are interested in:
<metric name="SupplierClasses" domain="class">
<description>The supplier classes of which the class
is a client in a dependency.</description>
<projection relation="depclient" target="dependency"
element="depsupplier" eltype="class" />
</metric>
This projection now only returns supplier classes (s1 and s2 for class
c in the above example).Note that the value of the "element" attribute is a metric expression. In addition to cross-reference attributes, you can specify arbitrary metric expressions that return model elements, e.g., following a chain of references using the dot operator (see Section 8.5.1.5 "Special Operators").
Like the "target" attribute, you can filter several element types with the "eltype" attribute. Just separate the additional element types with a "|", for example: eltype="class|interface|datatype".
| Prev | Up | Next |
| Section 8.1.1.3 "Filter Attribute "target"" | Contents | Section 8.1.1.5 "Filter Attributes "condition" and "targetcondition"" |