SDSU CS 696: Advanced OO
Spring Semester, 1997
Doc 8, Metrics part 2

To Lecture Notes Index
San Diego State University -- This page last updated Feb 25, 1997
----------

Contents of Doc 8, Metrics part 2

McCabe's Cyclomatic Complexity slide # 2
Henderson-Sellers' Recommended OO Metric Suite slide # 4
...Inside a class slide # 4
...Metrics External at the Class level slide # 6
...System Level but Ignoring Relationships - Metrics slide # 7
...System-Level Relationships but Excluding Inheritance slide # 8
...Inheritance Coupling slide # 9


Doc 8, Metrics part 2 Slide # 1
References

Henderson-Sellers, 1996, Object-Oriented Metrics: Measures of Complexity, Prentice Hall


Doc 8, Metrics part 2 Slide # 2

McCabe's Cyclomatic Complexity

Logic Structure Metric

Let G be a connected, directed acyclic graph (DAG) with e edges and n nodes

The cyclomatic complexity (or cycle rank) of G is defined as:

V(G) = e - n + 2



Doc 8, Metrics part 2 Slide # 3
Cyclomatic Complexity and Code Complexity

if ( A< B ) then
W;
else
X;
endif A = 3;


V(G) = 2

if ( A< B ) then 
W;
else
if ( B < C ) then
X;
else
Z;
endif
endif


V(G) = 3


switch( A )
case 1: X; break;
case 2: Y; break;
case 3: Z; break;
end case


V(G) = 3



Doc 8, Metrics part 2 Slide # 4

Henderson-Sellers' Recommended OO Metric Suite

Inside a class


Assume that a class has:
n public methods
m public data members
r private methods
s private data members

Control Flow Complexity

For each class compute:

Note the class total for V(G) is one interpretation of WMC


Doc 8, Metrics part 2 Slide # 5
Inside a class - Metrics

Method Size

For each class compute:


Class Size


Other Class Metrics


Note the ratios preconditions/method and postconditions/method should tend to unity

Doc 8, Metrics part 2 Slide # 6

Metrics External at the Class level


Queries are methods that return a value
Commands are methods that don't return a value


Let Args = total number of arguments in all methods of a class
Then

c'k = ck + Args
q'k = qk+ Args


Doc 8, Metrics part 2 Slide # 7

System Level but Ignoring Relationships - Metrics


"A useful insight into the 'object-orientedness' of the design can be gained from the system wide distribution of the class fan-out values. For example a system in which a single class has very high fan-out and all other classes have low or zero fan-outs, we really have a structured, not an OO , system"

NLM = number of local methods in the class
NRM = number of remote methods called by methods in the class

number of send statements defined in a class


Doc 8, Metrics part 2 Slide # 9

Inheritance Coupling


where:
U = (number of superclasses)/ total number of classes

S = (number of subclasses)/ (number of superclasses)

Extreme Values of U and S
Deep HierarchyWide Hierarchy
U1-0
S1+infinity

----------