Contents > B: List of Design Metrics > B.1 Class Metrics

B.1 Class Metrics

Metric: NumAttrCategory: Size
The number of attributes in the class.

The metric counts all properties regardless of their type (data type, class or interface), visibility, changeability (read only or not), and owner scope (class-scope, i.e. static, or instance attribute).

Not counted are inherited properties, and properties that are members of an association, i.e., that represent navigable association ends.

  • Also known as: NV (Number of Variables per class) [LK94].

Metric: NumOpsCategory: Size
The number of operations in a class.

Includes all operations in the class that are explicitly modeled (overriding operations, constructors, destructors), regardless of their visibility, owner scope (class-scope, i.e., static), or whether they are abstract or not. Inherited operations are not counted.

  • Also known as: WMC (Weighted method complexity) where each operation is assigned unity complexity [CK94].
  • Also known as: NM (Number of Methods) [LK94].


Metric: NumPubOpsCategory: Size
The number of public operations in a class.

Same as metric NumOps, but only counts operations with public visibility. Measures the size of the class in terms of its public interface.

  • Also known as: NPM (Number of Public Methods) [LK94].


Metric: SettersCategory: Size
The number of operations with a name starting with 'set'.

Note that this metric does not always yield accurate results. For example, an operation settleAccount will be counted as setter method.


Metric: GettersCategory: Size
The number of operations with a name starting with 'get', 'is', or 'has'.

Note that this metric does not always yield accurate results. For example, an operation isolateNode will be counted as getter method.


Metric: NestingCategory: not specified
The nesting level of the class (for inner classes).

Measures how deeply a class is nested within other classes. Classes not defined in the context of another class have nesting level 0, their inner classes have nesting level 1, etc. Nesting levels deeper than 1 are unusual; an excessive nesting structure is difficult to understand, and should be revised.


Metric: IFImplCategory: Inheritance
The number of interfaces the class implements.

This only counts direct interface realization links from the class to the interface. For example, if a class C implements an interface I, which extends some other interfaces, only interface I will be counted, but not the interfaces that I extends (even though class c implements those interfaces, too).


Metric: NOCCategory: Inheritance
The number of children of the class (UML Generalization).

Similar to export coupling, NOC indicates the potential influence a class has on the design. If a class has a large number of children, it may require more testing of the methods in that class. A large number of child classes may indicate improper abstraction of the parent class.


Metric: NumDescCategory: Inheritance
The number of descendents of the class (UML Generalization).

Counts the number of children of the class, their children, and so on.

  • See also: NOC (Number of Children).
  • Suggested in [LC94] and [TSM92].


Metric: NumAncCategory: Inheritance
The number of ancestors of the class.

Counts the number of parents of the class, their parents, and so on. If multiple inheritance is not used, the metric yields the same values as DIT.


Metric: DITCategory: Inheritance
The depth of the class in the inheritance hierarchy.

This is calculated as the longest path from the class to the root of the inheritance tree. The DIT for a class that has no parents is 0.

Classes with high DIT inherit from many classes and thus are more difficult to understand. Also, classes with high DIT may not be proper specializations of all of their ancestor classes.


Metric: CLDCategory: Inheritance
Class to leaf depth. The longest path from the class to a leaf node in the inheritance hierarchy below the class.
  • Defined in [TSM92].
  • See also: NOC (Number of Children).


Metric: OpsInhCategory: Inheritance
The number of inherited operations.

This is calculated as the sum of metric NumOps taken over all ancestor classes of the class.

  • Also known as NMI [LK94].
  • See also: DIT.


Metric: AttrInhCategory: Inheritance
The number of inherited attributes.

This is calculated as the sum of metric NumAttr taken over all ancestor classes of the class.

  • Loosely based on AIF in [AGE95].


Metric: Dep_OutCategory: Coupling (import)
The number of elements on which this class depends.

This metric counts outgoing plain UML dependencies and usage dependencies (shown as dashed arrows in class diagrams, usage with 'use' stereotype).


Metric: Dep_InCategory: Coupling (export)
The number of elements that depend on this class.

This metric counts incoming plain UML dependencies and usage dependencies (shown as dashed arrows in class diagrams, usage with 'use' stereotype).


Metric: NumAssEl_sscCategory: Coupling
The number of associated elements in the same scope (namespace) as the class.

For instance, for a class that is defined in a package p, this counts only associations with classes, interfaces, etc. in the same package p. Such associations are encouraged, because they do not cross the package boundary, and contribute to the cohesion of the package.

This metric does not distinguish plain, aggregate, or composite associations, as well as incoming, outgoing, or bidirectional associations; all such associations are counted.


Metric: NumAssEl_sbCategory: Coupling
The number of associated elements in the same scope branch as the class.

For instance, for a class that is defined in a package p, this metric only counts associations with model elements

  • in p itself,
  • in packages that p contains (subpackages, sub-subpackages etc. of p),
  • in packages that contain p (packages of which p is a subpackage, sub-subpackage etc).
Such associations cross package boundaries, but one of the packages is nested within the other. Therefore, a dependency between the packages is expected, anyway.
  • Note: Like metric NumAssEl_ssc, direction and aggregation of the associations are ignored.


Metric: NumAssEl_nsbCategory: Coupling
The number of associated elements not in the same scope branch as the class.

For a class that is defined in a package p, this counts only associations with model elements in packages that neither contain p nor are contained by p. These are the least desirable associations, because they couple otherwise unrelated packages. Such associations cannot be avoided, but their use should be minimized.

  • Note: Like metric NumAssEl_ssc, direction and aggregation of the associations are ignored.


Metric: EC_AttrCategory: Coupling (export)
The number of times the class is externally used as attribute type.

This is the number of attributes in other classes that have this class as their type.

  • Version of: OAEC+AAEC in [BDM97].


Metric: IC_AttrCategory: Coupling (import)
The number of attributes in the class having another class or interface as their type.
  • Version of: OAIC+AAIC in [BDM97].
  • Also known as: DAC (data abstraction coupling) [LH93].


Metric: EC_ParCategory: Coupling (export)
The number of times the class is externally used as parameter type.

This is the number of parameters defined outside this class, that have this class as their type.

  • Version of: OMEC+AMEC in [BDM97].


Metric: IC_ParCategory: Coupling (import)
The number of parameters in the class having another class or interface as their type.
  • Version of: OMIC+AMIC in [BDM97].


Metric: ConnectorsCategory: Complexity
The number of connectors owned by the class.


Metric: InstSpecCategory: not specified
The number of instance specification where the class is a classifier.

Similar to export coupling, the more instances of the class there are, the larger the role of the class in the system.


Metric: LLInstCategory: not specified
The number of lifelines that represent a property of which this class is the type.

Similar to export coupling, the more lifelines there are of the class, the larger the role of the class in the system.


Metric: MsgSentCategory: Coupling (import)
The number of messages sent.

Counts the number of messages that instances of this class send to instances of other classes, or unclassified instances.

  • Version of OMMIC+AMMIC in [BDM97].


Metric: MsgRecvCategory: Coupling (export)
The number of messages received.

Counts the number of messages that instances of this class receive from instances of other classes or unclassified instances.

  • Version of OMMEC+AMMEC in [BDM97].


Metric: MsgSelfCategory: Complexity
The number of messages sent to instances of the same class.

Counts the number of messages that instances of this class send to themselves or to other instances of the same class.

  • Version of ICH in [LLW95].


Metric: DiagsCategory: Diagram
The number of times the class appears on a diagram.