Depth of Inheritance Tree

CachéQuality release 
CachéQuality 1.0.0
Domain 
Code metrics
Scope 
Class

The Depth of Inheritance Tree (DIT) metric provides for each class a measure of the inheritance levels from the object hierarchy top. The minimum value of DIT for a class is 1.

A DIT value of 0 indicates a root while a value of 2 and 3 indicates a higher degree of reuse. If there is a majority of DIT values below 2, it may represent poor exploitation of the advantages of OO design and inheritance. It is recommended a maximum DIT value of 5 since deeper trees constitute greater design complexity as more methods and classes are involved.

Method of calculation

Since ObjectScript supports multiple inheritance, for each declaration such as:

Class A Extends (B1, B2)

the Depth of Inheritance Tree is the maximum level reached by walking the dependency tree of A, then B1 and B2, recursively so until an element is encountered which does not Extends anything.

On next example, the DIT value is 4 (the green hierarchy):