Object Oriented Metrics

Object-Oriented Analysis and Design of software provide many benefits such as reusability, decomposition of problem into easily understood object and the aiding of future modifications. But the OOAD software development life cycle is not easier than the typical procedural approach. Therefore, it is necessary to provide dependable guidelines that one may follow to help ensure good OO programming practices and write reliable code. Object-Oriented programming metrics is an ascpect to be considered. Metrics to be a set of standards against which one can measure the effectiveness of Object-Oriented Analysis techniques in the design of a system.

OO metrics which can be applied to analyze source code as an indicator of quality attributes. The source code could be any OO language.

Metrics for OO Software Development Environments

In his master's thesis Morris [Morris 1989] made some important observations on OO code and proposed candidate metrics for productivity measurement :

Methods per Class

Average number of methods per object class = Total number of methods / Total number of object classes

Inheritance Denpendencies

Inharitance tree depth = max ( inheritance tree path length )

Degree of Coupling Between Objects

Average number of uses dependencies per object = total number of arcs / total number of objects

arcs = max ( number of uses arcs ) - in an object uses network

arcs - attached to any single object in a uses network

Degree of Cohesion of Objects

Degree of Cohesion of Objects = Total Fan-in for All Objects / Total No. of Objects

Object Library Effectiveness

Average number = Total Number of Object Reuses / Total Number of Library Objects

Factoring Effectiveness

Factoring Effectiveness = Number of Unique Methods / Total Number of Methods

Degree of Reuse of Inheritance Methods

Percent of Potential Method Uses Actually Reused (PP):
PP = ( Total Number of Actual Method Uses / Total Number of Potential Method Uses ) x 100

Percent of Potential Method Uses Overridden (PM):
PM = ( Total Number of Methods overrridden / Total Number of Potential Method Uses ) x 100

Average Method Complexity

Average method complexity = Sum of the cyclomatic complexity of all Methods / Total number of application methods

Application Granularity

Application granularity = total number of objects / total function points

Chidamber & Kemerer's Metics Suite[Chidamber and Kemerer]

Chidamber and Kemerer's metrics suite for OO Design is the deepest reasearch in OO metrics investigation. They have defined six metrics for the OO design.

Weighted Methods per Class ( WMC )
It is defined as the sum of the complexities of all methods of a class.

Depth of Inheritance Tree (DIT)
It is defined as the maximum length from the node to the root of the tree.

Number of Children (NOC)
It is defined as the number of immediate subclasses.

Coupling between object classes (CBO)
It is defined as the count of the classes to which this class is coupled. Coupling is defined as : Two classes are coupled when methods declared in one class use methods or instance variables of the other class. [Chidamber and Kemerer 1994]

Response For a Class (RFC)
It is defined as number of methods in the set of all methods that can be invoked in response to a message sent to an object of a class.

Lack of Cohesion in Methods (LCOM)
It is defined as the number of different methods within a class that reference a given instance variable.

Advantages

  1. They appeared from the nature from the OO approach
  2. NOC and RFC metrics give some idea as to budgeting for testing that class.

Drawbacks

  1. Measuring comlexity of a class is subject to bias
  2. They cannot give a good size and effort estimation of software
  3. These metrics seem only to bring the design phase into play, and does not provide adequate coverage in terms of planning

MOOD ( Metrics for Object Oriented Design )

The MOOD metrics set refers to a basic structural mechanism of the OO paradigm as encapsulation ( MHF and AHF ), inheritance ( MIF and AIF ), polymorphishm ( PF ) , message-passing ( CF ) and are expressed as quotients. The set includes the following metrics :

Method Hiding Factor ( MHF )

MHF is defined as the ratio of the sum of the invisibilities of all methods defined in all classes to the total number of methods defined in the system under consideration.

The invisibility of a method is the percentage of the total classes from which this method is not visible.
note : inherited methods not considered.

Attribute Hiding Factor ( AHF )

AHF is defined as the ratio of the sum of the invisibilities of all attributes defined in all classes to the total number of attributes defined in the system under consideration.

Method Inheritance Factor ( MIF )

MIF is defined as the ratio of the sum of the inherited methods in all classes of the system under consideration to the total number of available methods ( locally defined plus inherited) for all classes.

Attribute Inheritance Factor ( AIF )

AIF is defined as the ratio of the sum of inherited attributes in all classes of the system under consideration to the total number of available attributes ( locally defined plus inherited ) for all classes.

Polymorphism Factor ( PF )

PF is defined as the ratio of the actual number of possible different polymorphic situation for class Ci to the maximum number of possible distinct polymorphic situations for class Ci.

Coupling Factor ( CF )

CF is defined as the ratio of the maximum possible number of couplings in the system to the actual number of couplings not imputable to inheritance.

In the MOOD Project Home Page you can find papers, and MOOD estimation tools about MOOD.

Estimating With Objects - Watts S. Humphrey's[Humprey 1996]

Sencer's Home Software Measurement Page
sencer@hun.edu.tr
This page is maintained by Ümit Karakaş and Sencer Sultanoğlu
Last modified Oct 15, 98