Avoid Concrete Class References in Interfaces
WarningClean ABAP & Modern Syntax#EC NO_INTF_CLASS_REFLocal Only
Overview
Interfaces should not reference concrete classes.
ATC Finding Message:
Interface references concrete class; use an interface reference instead
Rationale
Interfaces should adhere to the Dependency Inversion Principle and not couple directly to concrete class implementations. Use interface references instead.
Non-Compliant
abap
INTERFACE lif_demo.
DATA mo_obj TYPE REF TO cl_concrete.
ENDINTERFACE.Compliant
abap
INTERFACE lif_demo.
DATA mo_obj TYPE REF TO if_contract.
ENDINTERFACE.Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC NO_INTF_CLASS_REF
" SAP CI_ prefix format:
... "#EC CI_NO_INTF_CLASS_REFRelated Rules
- Prefer Interface Segregation (Small, Focused Interfaces) —
#EC PREF_INTF_SEGREG - Avoid Exposed Mutable Data in Classes and Interfaces —
#EC PUBLIC_ATTR
Technical Details
- Native ATC Class:
ZCL_SKYLINT_NO_INTF_CLASS_REF - Implementation File: zcl_skylint_no_intf_class_ref.clas.abap