Depth of Inheritance Tree (DIT)
Overview
Inheritance,
otherwise referred to as generalization, is a key
concept in the object model and must be carefully used. A class situated too deeply in the
inheritance tree will be relatively complex to develop, test and maintain. It is useful, therefore, to know and regulate
this depth.
This
metric provides the position of the class in the inheritance tree.
Computation
For
multiple inheritance, this metric
provides the maximum length path.
· DIT (C0) = 0
· DIT (C0’) = 0
· DIT (C1) = 1
· DIT (C2) = 2
· DIT (C3) = 3
· DIT (C4) = 4

Figure 23 - Depth inheritance computation for a class
Nominal range
Between
0 and 4.
Analysis
A
compromise between the high performance power provided by inheritance and the
complexity which increases with the depth must be found. A value of between 0 and 4 respects this
compromise.
A value greater than 4 would compromise encapsulation and increase complexity.