SDMetrics home page
The Software Design Metrics tool for the UML

User-defined metrics and design rules

Usage of the UML varies greatly among software organizations, in the level of detail the UML is applied, the types of diagrams that are created, the rigor with which the UML is applied, and the ways in which the extension mechanisms of the UML are used.

SDMetrics enables you to measure any design aspect which you think is important in the way you use the UML in your development processes. With SDMetrics, you can define your own design rules and metrics, tailored to your design practices!

SDMetrics reads the definitions of its metrics and design rules from an XML-based configuration file. You can download several metric definition files from the Project Files Page, or write your own metric definitions.

Definition of metrics

The following is an example of a simple metric that counts the number of public operations in a class:

<metric name="NumPubOps" domain="class" category="Size">
 <description>The number of public operations in a class.</description>
 <projection relset="ownedoperations" condition="visibility='public'"/>

This XML code instructs SDMetrics to count all elements referenced via the "ownedoperations" attribute of the class, that have an attribute "visibility" with value "public".

Section 8.1 of the SDMetrics user manual describes the definition of metrics in detail. You can also extend the formalism to define new metrics itself, see Section 9 of the user manual.

Definition of rules

Here is the definition of a rule that checks classes, interfaces etc. for public attributes that are not constant:

<rule name="PublicAttr" domain="property" category="Style">
 <description>Non-constant attribute is public.</description>
 <violation condition="visibility='public' and isreadonly!='true'"/>

The rule reports any attributes (properties in UML2 speak) with public visibility that are not marked as "read only". Section 8.3 of the SDMetrics user manual describes in detail how to define your own rules.

What about using OCL for rule checking? See the FAQ.

The metrics and rule engine

The Java API to access the engines is available here. The source code of the metrics and rule checking engine is included in the SDMetrics Open Core distribution, available under the GNU Affero General Public License.

The metrics and rule engine can also be licensed commercially.