Skip to main content

Depth of Inheritance Tree

Maximum inheritance path from the class to the root class.

The deeper a class is in the hierarchy, the more methods and variables it is likely to inherit, making it more complex. Deep trees as such indicate greater design complexity. Inheritance is a tool to manage complexity, really, not to not increase it. As a positive factor, deep trees promote reuse because of method inheritance.

A recommended DIT is 5 or less.

info

When a class inherits directly from Object (or has no extends), DIT=1.

Additional resources:

Config example

dart_code_metrics:
...
metrics:
...
depth-of-inheritance-tree: 5
...