_OOMETR Object-oriented Metrics Report

Top  Previous  Next

 

Targets: All

 

This report has six different sections, each calculating and displaying an important metrics:

 

Weighted methods per class (WMC)

Depth of inheritance tree (DIT)

Number of children (NOC)

Coupling between object classes (CBO)

Response for a class (RFC)

Lack of cohesion in methods (LCOM)

 

For more detailed reading about these metrics, their theory and implementation, see http://www.pitt.edu/~ckemerer/clnieee.pdf.

 

 

Weighted methods per class (WMC) (OOME1)

 

The number of methods in a class predicts the time and effort needed to develop and maintain the class. In the PAL implementation, the mean decision-point (DP) is calculated for the class. This is presented together with the DP for each method in the class.

 

 

Weighted Methods per Class (WMC):

----------------------------------------------------------------------------

 

BAbout.TAboutBox (WMC=2,0)............................. BAbout (14)        

CmdLicenseClick (PM) (DP=1).......................... BAbout\TAboutBox (34)

Create (C) (DP=1).................................... BAbout\TAboutBox (48)

FillControls (PM) (DP=4)............................. BAbout\TAboutBox (45)

 

BCat.TPegCategory (WMC=0,7)............................ BCat (23)          

Create (C) (DP=0).................................... BCat\TPegCategory (80)

ReadStream (PM) (DP=1)............................... BCat\TPegCategory (82)

WriteStream (PM) (DP=1).............................. BCat\TPegCategory (83)

 

 

Depth of inheritance tree (DIT) (OOME2)

 

The deeper a class hierarchy is, the more complex it becomes. Deep trees indicate greater complexity, but also promote code reuse because of inheritance.

 

DIT is calculated as the number of classes traversed from the actual class to the root class. Because every class inherits from TObject, this number is at least 1. For a class that inherits from an unknown class (a class for which code has not been found) has a number of 2. This is because the unknown class has at least DIT=1.

 

 

Depth of Inheritance Tree (DIT):

----------------------------------------------------------------------------

 

BAbout.TAboutBox (DIT=2)............................... BAbout (14)        

BCat.TPegCategory (DIT=1).............................. BCat (23)          

BCat.TPegCategoryHandler (DIT=1)....................... BCat (25)          

BCat.TPegCategoryList (DIT=1).......................... BCat (22)          

BFile.EIncludeBroken (DIT=2)........................... BFile (12)        

BLicFrm.TSettingsDialog (DIT=2)........................ BLicFrm (14)      

BRes.TPegResource (DIT=1).............................. BRes (23)          

BRes.TPegResourceHandler (DIT=1)....................... BRes (25)          

BRes.TPegResourceList (DIT=1).......................... BRes (22)          

 

 

Number of children (NOC) (OOME3)

 

This number is calculated as the immediate number of children for a given class.

A high number indicates high code reuse. A large number of children could also mean a bad abstraction of the parent class.

 

 

Number of Children (NOC):

----------------------------------------------------------------------------

 

BAbout.TAboutBox (NOC=0)............................... BAbout (14)        

BCat.TPegCategory (NOC=0).............................. BCat (23)          

BCat.TPegCategoryHandler (NOC=0)....................... BCat (25)          

GFiles.TAbstractFile (NOC=2)........................... GFiles (43)        

 

 

Coupling between object classes (CBO) (OOME4)

 

Two classes are coupled when methods in one class use methods, properties or fields in another class. This is counted both ways, it does not matter which class that calls the other.

 

A high number for CBO is not desirable. It means that the class is less independent or less loosely coupled. A low number for CBO on the other hand, the easier it is to reuse it in another project.

 

 

Coupling between Object Classes (CBO):

----------------------------------------------------------------------------

 

BAbout.TAboutBox (CBO=2)............................... BAbout (14)

OvcRLbl.TOvcRotatedLabel............................. OvcRLbl (126)

OvcURL.TOvcURL....................................... OvcURL (54)

 

BCat.TPegCategory (CBO=5).............................. BCat (23)

TdPrnWiz.TPrintWizardDialog.......................... TdPrnWiz (19)

TdMain.TTodoMainForm................................. TdMain (19)

TdEdCat.TTdEditCategoryDialog........................ TdEdCat (14)

BCat.TPegCategoryHandler............................. BCat (25)

BCat.TPegCategoryList................................ BCat (22)

 

 

Response for a class (RFC) (OOME5)

 

The response number for a class is the number of methods or procedures that can be potentially executed if a message (for example a function call) is received by the class.

 

It is defined as

 

RFC = M + R

 

where

 

M = number of methods in the class

R = number of remote methods directly called by methods of the class  

 

RFC counts only the first level of calls outside the class. It is calculated by following all calls from methods in the class, if these calls lead to methods in other classes or to procedures or functions. Every given method/subprogram is only counted once.

 

A large number for RFC indicates that the class is complex and hard to understand. It means that more time must be given for testing and debugging.

 

 

Response for a Class (RFC):

----------------------------------------------------------------------------

 

BAbout.TAboutBox (RFC=3)............................... BAbout (14)        

BCat.TPegCategory (RFC=3).............................. BCat (23)          

BCat.TPegCategoryHandler (RFC=14)...................... BCat (25)          

BCat.TPegCategoryList (RFC=6).......................... BCat (22)          

BFile.EIncludeBroken (RFC=0)........................... BFile (12)        

BLicFrm.TSettingsDialog (RFC=4)........................ BLicFrm (14)      

BRes.TPegResource (RFC=2).............................. BRes (23)          

BRes.TPegResourceHandler (RFC=13)...................... BRes (25)          

BRes.TPegResourceList (RFC=6).......................... BRes (22)          

 

 

Lack of cohesion of methods (LCOM) (OOME6)

 

A class that is cohesive performs one and only one function. Lack of cohesion means the class performs more than one function.

 

LCOM = P – Q, if P > Q

 

else

 

LCOM = 0

 

 

The number is calculated by taking each possible pair of methods in the class. If they access the same field, increase Q by one. If they don’t, increase P by one.

 

LCOM = 0 means a cohesive class.

 

If LCOM > 0, the class could be split into two or more classes. A high LCOM indicates that the class is error-prone.

 

 

Lack of Cohesion in Methods (LCOM):

----------------------------------------------------------------------------

 

BAbout.TAboutBox (LCOM=0).............................. BAbout (14)        

BCat.TPegCategory (LCOM=0)............................. BCat (23)          

GEnhLb.TEnhancedListBox (LCOM=13)...................... GEnhLb (16)        

GFiles.TBinaryFile (LCOM=26)........................... GFiles (51)        

GFiles.TTextFile (LCOM=0).............................. GFiles (118)      

GFrView.TFrPreviewDialog (LCOM=0)...................... GFrView (16)      

GGlyphLb.TGlyphListBox (LCOM=0)........................ GGlyphLb (14)      

GNag.TNagDialog (LCOM=0)............................... GNag (15)          

GSapi.TSapiVoice (LCOM=0).............................. GSapi (13)        

TdApp.TTodoAppHandler (LCOM=0)......................... TdApp (16)        

TdArch.TTdViewArchiveDialog (LCOM=1)................... TdArch (14)        

TdCommon.TCommonModule (LCOM=0)........................ TdCommon (16)      

TdEdCat.TTdEditCategoryDialog (LCOM=4)................. TdEdCat (14)      

 

 

See also:

 

R_METRIC Metrics Reports