Design for Inheritance or Prohibit It (FINAL)
WarningClean ABAP & Modern SyntaxQuickFix Ready#EC PREF_FINAL_CLASSRemote Enabled
Overview
Prefer FINAL classes and methods by default.
ATC Finding Messages:
Classes should be marked FINAL by default unless designed for inheritanceDeclare method as FINAL if it is not intended to be redefined
Rationale
A class that is not designed for inheritance can still be subclassed, and subclasses may depend on internal behavior that later changes. Marking the class FINAL prevents fragile base class problems and documents that no extension is intended. Remove FINAL only when the class has documented extension points.
Non-Compliant
abap
CLASS cl_customer_service DEFINITION
PUBLIC CREATE PUBLIC.
PUBLIC SECTION.
METHODS execute.
ENDCLASS.Compliant
abap
CLASS cl_customer_service DEFINITION
PUBLIC FINAL CREATE PUBLIC.
PUBLIC SECTION.
METHODS execute.
ENDCLASS.Automated QuickFix
This rule provides an automated QuickFix directly in Eclipse ABAP Development Tools (ADT):
- Position the cursor on the flagged statement.
- Press Ctrl + 1 (Quick Assist).
- Select the automated refactoring to apply the clean syntax immediately.
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 |
|---|---|---|---|
CHECK_CLASSES | Boolean | true | Enforce FINAL on classes not designed for inheritance |
CHECK_METHODS | Boolean | true | Enforce FINAL on methods not designed to be redefined |
Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC PREF_FINAL_CLASS
" SAP CI_ prefix format:
... "#EC CI_PREF_FINAL_CLASSRelated Rules
- Limit Class Inheritance Depth (Favor Composition over Inheritance) —
#EC MAX_INHERIT - Prefer CREATE_* Prefix for Factory Methods Returning Own Class —
#EC PREF_FACTORY_NAME - Prefer Composition over Inheritance —
#EC PREF_COMPOSITION
Technical Details
- Native ATC Class:
ZCL_SKYLINT_PREF_FINAL_CLS - Implementation File: zcl_skylint_pref_final_cls.clas.abap