Skip to content

Limit Inheritance Depth ​

WarningMetrics & Complexity Limits#EC INHERIT_DEPTHLocal Only

Overview ​

Avoid deep class inheritance hierarchies.

ATC Finding Message: Avoid deep class inheritance; prefer composition over inheritance

Rationale ​

Deep inheritance chains make behavior depend on many superclasses and expose subclasses to the fragile base class problem. A change near the root can affect every descendant and is hard to test completely. Prefer composition and keep class hierarchies shallow.

Non-Compliant ​

abap
CLASS lcl_level1 DEFINITION.
ENDCLASS.
CLASS lcl_level2 DEFINITION INHERITING FROM lcl_level1.
ENDCLASS.
CLASS lcl_level3 DEFINITION INHERITING FROM lcl_level2.
ENDCLASS.
CLASS lcl_level4 DEFINITION INHERITING FROM lcl_level3.
ENDCLASS.
CLASS lcl_level5 DEFINITION INHERITING FROM lcl_level4.
ENDCLASS.

Compliant ​

abap
CLASS lcl_worker DEFINITION.
  PRIVATE SECTION.
    DATA mo_engine TYPE REF TO if_engine.
ENDCLASS.

Configuration & Thresholds ​

This check can be fine-tuned directly in the ATC Check Variant Editor (CHKV) in Eclipse ADT:

Parameter NameData TypeDefault Value
MAX_DEPTHInteger3

Suppression ​

To suppress findings for this rule, append the pseudo-comment to the statement:

abap
" Standard pseudo-comment:
... "#EC INHERIT_DEPTH

" SAP CI_ prefix format:
... "#EC CI_INHERIT_DEPTH

Technical Details ​

Released under the MIT License.