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

8.1 Definition of Metrics

A metric is defined with an XML element as follows:
<metric name="metricname" domain="metricdomain" category="metriccategory"
  internal="true/false" inheritable="true/false"> 
  <description>Description of the metric.</description>
  <'metric definition' ...>
</metric>
The attributes in the opening "metric" tag are as follows: Note that metrics for one domain must have unique names (i.e., you cannot define two metrics named "NumOps" for classes). You can have metrics of the same name for different domains (e.g., a metric "NumOps" for classes, and a metric "NumOps" for interfaces).

Following the metric tag is an optional description of the metric, which will be shown in the measurement catalog (see Section 4.13 "The View 'Catalog'"). Section 8.6 "Writing Descriptions" explains how to write metric descriptions.

Following the description is an XML element that defines the calculation procedure for the metric. We describe each calculation procedure in detail in the following subsections.


8.1.1 Projection
8.1.2 Compound Metrics
8.1.3 Attribute Value
8.1.4 Nesting
8.1.5 Signature
8.1.6 Connected Components
8.1.7 Value Filter
8.1.8 Subelements
8.1.9 Substring