Filename jm_MetricsGuide.html, author Tobias Mayer, v05j Date 17 August1998 (last updated 07 August 1999)

Go to User Guide


 JMeasure

Java object-orientated metrics tool

Metrics Guide: (v0.5_beta1)

The eleven Object Orientated Design Metrics used by the metrics tool, JMeasure, are defined here. All metrics are language-independent but are defined here in terms of the Java programming language.

The metrics set is based on the original suite of six metrics proposed by Chidamber & Kemerer in their 1994 paper, "A Metrics Suite for Object Orientated Design", published in IEE Transactions on Software Engineering (vol. 20 No.6). Three of the original six metrics have been re-defined (and one has been dropped), based on more recent research (see Note below), and additional (complimentary) metrics have been added to make up the full set.

The attributes of size, complexity, inheritance, reusability and encapsulation are measured. The metrics set is intended to be used by system designers and managers to ensure that agreed design principles are being adhered to. The results produced by this set of metrics will highlight faults and anomalies in the design of the package or system being analyzed. The file jm_ResultsGuide.html provides a guide for interpreting the results produced by the Java metrics tool, JMeasure.

 

Note: A paper, "A critical analysis of current OO design metrics", which focuses on the work off Chidamber & Kemerer, was presented at the BCS SQM'99 conference in Southampton on 29 March 1999. Copies can be obtained from the SQM site.

Summary:

Acronym

Name

Summary of Usage

TYP

Type of class

Basic categorization, (indicates system level of abstraction)

PPC

Properties Per Class

Class size

DIT

Depth of Inheritance Tree

Inheritance, structure

NOA

Number of Ancestors

Inheritance, structure, 'Fan-in' measurement

NOC

Number of Children

Extendibility, structure, influence

NOD

Number of Descendants

Extendibility, structure, influence, 'Fan-out' measurement

NCC

Number of Client Classes

Influence, package cohesion

NSC

Number of Supplier Classes

Dependencies, package cohesion

Uni

Class Unity value

 Encapsulation measure: class cohesion

Vis

Data Visibility Level

 Encapsulation measure: Level of privacy of data, class 'security'

MOv

Method Overrides

 (potential) polymorphism

 

note: the term 'this class' is used throughout to mean 'the class that is being measured'.

 

OO Metrics Descriptions

TYP TYPe of class

Each Java class is rated as one of the following:

It is further rated as either: 

The class type and level of visibility are useful to know when understanding the implications of the other results.


 

PPC is an indicator of a class's size.

PPC Properties Per Class

Count of all explicit properties of a class: Constructors + Methods + Fields. Properties added by the Java compiler, e.g. default constructors, enclosing class references, etc. are purposely excluded from this count.


DIT, NOA, NOC and NOD are measures of inheritance/extendibility. They are applied in different ways to classes and interfaces. Details follow each metric.

 

DIT Depth of Inheritance Tree

Depth of nesting in the hierarchy, the root class - usually 'java.lang.Object' - being considered as level 0. If the "Restrict to Package" option is used the highest class that can be located in the current package will be considered as level 0.

NOA Number of Ancestors

A measure of the amount of influence due to inheritance. NOA counts all classes that a class extends (i.e. the DIT count) plus:

for classes: count of all interfaces that a class implements: a) directly, i.e. with the 'implements' clause, b) indirectly, i.e. the 'super-interfaces' of the implemented interfaces, c) indirectly, i.e. the implemented interfaces of all super-classes.

for interfaces: count of all interfaces that an interface extends: a) directly, i.e. with the extends clause, b) indirectly, i.e. the 'super-interfaces' of the extended interfaces.

If the "Restrict to Package" option is used only interfaces in the current package will be counted.

NOC Number of Children

for classes: count of all immediate subclasses, i.e. classes that directly extend this class.

for interfaces: count of the number of classes that directly implement the interface being measured + the number of interfaces that immediately extend the interface being measured.

Restricted to the package being analyzed.

NOD Number of Descendants

for classes: count of all descendant classes, i.e. all classes that extend this class either directly or indirectly.

for interfaces: count of the number of classes that implement this interface, either directly or indirectly + count of the number of interfaces that extend this interface, either directly or indirectly.

Restricted to the package being analyzed.


 

NCC & NSC measure the inter-connectedness of the package. The total inter-connectedness measure for a class is defined as the set of all (directly) connected classes, i.e. NCC È NSC.

Inter-connectedness is measured from two viewpoints:

i) the set of classes that use this class (NCC)

ii) the set of classes that this class uses (NSC)

The idea of inter-connectedness replaces Chidamber & Kemerer's concept of OOD 'Coupling'. Its advantage is that it does not have the negative connotation that Coupling carries over from function-orientated design, i.e. it is not necessarily undesirable for a class to have a high inter-connectedness value.

NCC Number of Client Classes

Count of all classes in the package that make use of one or more of the services provided by this class. The count excludes classes that have some other relationship with this class, i.e. ancestors, descendants, own inner classes, own enclosing classes and classes that are defined in the same enclosing class as this class.

NSC Number of Supplier Classes

NSC is a count of all classes in the package that this class makes direct use of. It is the inverse of the NCC metric. The classes in this measure are said to be 'directly connected' to this class, where 'directly connected' is defined as:

class X is directly connected to class Y if, and only if

X declares an object of type Y as a field or a method return value OR X receives an object of type Y as a parameter to a method or constructor OR X declares an object of type Y as a local variable OR X throws an exception of type Y OR X references a static property of Y

As with NCC, the count excludes classes that have some other relationship with this class, i.e. ancestors, descendants, own inner classes, own enclosing classes and classes that are defined in the same enclosing class as this class.


 

Vis and Uni are concerned with the design of the class itself, independent from the package design. Both metrics are measured 'in reverse'. (In traditional metrics a low value is considered as 'desirable' and a high value as 'undesirable'. This holds true with both these metrics.)

Uni class UNIty value

Measure of the (lack of) similarity of methods in a class. Two methods are considered similar if they access one or more of the same instance fields. A measure of 1 indicates full unity, higher numbers imply progressively less unity.

Uni is a count of distinct clusters of methods, where a cluster is defined as a group of methods that are linked to each other, either directly or indirectly, through accessing the same field or set of fields, any one method in the cluster accessing at least one field which is accessed by at least one of the other methods in the cluster.

Note: Uni is essentially a re-naming of the Chidamber & Kemerer LCOM metric, however the definition used here is that proposed by Hitz and Montazeri in their correspondence paper, "Chidamber & Kemerer's metrics Suite: A Measurement Theory Perspective", (IEEE Transactions on Software Engineering, April 1996) and not that originally defined by Chidamber & Kemerer.

Uni is only concerned with instance fields and methods. Constructors and Instance Initializers are not considered as methods. This implementation also excludes the commonly used 'toString()' method (and 'paramString()' in java.awt classes) as this method is not usually part of a class's essential functionality and is likely to use most fields (if not every field) in the class, thus potentially giving a falsely low unity measure.

All methods that access zero instance fields are grouped together as one cluster. Often, such methods will simply call another method in the class, thus indirectly using the instance variables that the called method uses (this implementation of Uni does not measure indirect access). Grouping such methods together, while not strictly correct, gives a more accurate unity measurement than would be achieved by putting each method in its own cluster.

Vis Level of data VISibility

Measure of how visible (and therefore directly accessible) a class's data is. A class's data is considered hidden (invisible) if all its instance fields are private and can only be manipulated via methods. Vis uses a scale of 0-2 for each field, where 0=fully private, 1=partially private (i.e.. protected or package-visible) and 2=public. The final Vis value is on a scale of 0-100. The closer the total measurement is to zero the more hidden the data. Final fields are ignored, as their values cannot be reset so will not affect a class's overall data visibility level. Vis is a crude measure of data visibility but gives a reasonable picture of this aspect of a class. It is currently being revised based on the Attribute Hiding Factor (AHF) metric proposed by the MOOD Metrics team.


 

MOv Method Overrides

Count of the number of methods in this class that override a method in an ancestor class. This measure gives no indication of the quality of the overriding, i.e. it does not differentiate between methods that override ancestor methods for convenience (usually undesirable) and those that implement or specialize ancestor methods (usually desirable). An improved version of this metric (possibly two metrics) that will make this distinction is currently being developed.



End of Document

contact Tobias Mayer for further information.



Hosted by www.Geocities.ws

1