Contents > 8 Defining Custom Design Metrics and Rules > 8.1 Definition of Metrics > 8.1.5 Signature

8.1.5 Signature

The signature procedure creates signature strings such as the name and parameter list of an operation.
<metric name="Signature" domain="operation" >
  <description>The signature of an operation.</description>
  <signature set="OPParameters" element="parametertype" />
</metric>
The elements that constitute the parameter list are specified by attribute set. Each element in the set can be subjected to the usual filters (target, element, eltype, condition, targetcondition, scope). In the above example, set OPParameters is defined to be the set of parameters of the operation, and we include the type of each parameter in the signature instead of the parameter itself.

The result is a string that contains the name of the operation, and the IDs of the types of the parameters in the order the parameters are defined in the XMI source file, for example 'getBalance(xmi4893,xmi238011)'. With these strings you can build, for instance, signature sets of the operations of a class and define metrics dealing with method overriding.

To obtain more human readable signature strings, you can further define the presentation of the elements on the signature list. The following definition generates signature strings such as 'getBalance[account:int; time:TimeStamp]':

<metric name="Signature2" domain="operation" >
  <description>Operation signature with brackets and parameter 
     names/types in the clear.</description>
  <signature prologue="name+'['" set="OPParameters" 
     value="name+':'+parametertype.name" separator="'; '" epilogue="']'" />
</metric>
The attributes to control the presentation are: