Skip to content

Prefer CREATE_* Prefix for Factory Methods Returning Own Class ​

WarningClean ABAP & Modern Syntax#EC PREF_FACTORY_NAMERemote Enabled

Overview ​

Factory methods should start with CREATE_.

ATC Finding Message: Factory method returning own class type should start with prefix

Rationale ​

Static factory methods returning an instance of their enclosing class should clearly communicate instantiation intent by following standard naming conventions starting with CREATE_ (e.g. create, create_instance).

Non-Compliant ​

abap
CLASS-METHODS build RETURNING VALUE(ro_obj) TYPE REF TO lcl_service.

Compliant ​

abap
CLASS-METHODS create_instance RETURNING VALUE(ro_obj) TYPE REF TO lcl_service.

Configuration & Thresholds ​

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

Parameter NameData TypeDefault ValueDescription & Guidance
PREFIXStringCREATE_Required prefix for static factory constructor methods (default: CREATE_)

Suppression ​

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

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

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

Technical Details ​

Released under the MIT License.