Prefer Interface Segregation (Small, Focused Interfaces)
WarningClean ABAP & Modern Syntax#EC PREF_INTF_SEGREGRemote Enabled
Overview
Prefer interface segregation (small interfaces).
ATC Finding Message:
Interface has too many methods; prefer interface segregation
Rationale
Fat interfaces force implementers to depend on methods they do not need and make test mock creation cumbersome. Break large interfaces into small, cohesive, role-based contracts adhering to the Interface Segregation Principle (ISP).
Non-Compliant
abap
INTERFACE lif_everything.
METHODS: read, write, print, send_email, archive, validate.
ENDINTERFACE.Compliant
abap
INTERFACE lif_reader.
METHODS read.
ENDINTERFACE.
INTERFACE lif_writer.
METHODS write.
ENDINTERFACE.Configuration & Thresholds
This check can be fine-tuned directly in the ATC Check Variant Editor (CHKV) in Eclipse ADT:
| Parameter Name | Data Type | Default Value | Description & Guidance |
|---|---|---|---|
MAX_METHODS | Integer | 5 | Maximum number of methods allowed in a single interface (Interface Segregation Principle, default: 5) |
Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC PREF_INTF_SEGREG
" SAP CI_ prefix format:
... "#EC CI_PREF_INTF_SEGREGRelated Rules
- Avoid Exposed Mutable Data in Classes and Interfaces —
#EC PUBLIC_ATTR - Prefer NEW #( ) over CREATE OBJECT —
#EC PREF_NEW_OPERATOR - Declare Constructor in PUBLIC SECTION —
#EC PREF_PUB_CTOR
Technical Details
- Native ATC Class:
ZCL_SKYLINT_PREF_INTF_SEGREG - Implementation File: zcl_skylint_pref_intf_segreg.clas.abap