💼 ABAP PACT DIFFICULTY: Adept Creational

Singleton in ABAP

Enterprise pact magic using the Singleton pattern.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Singleton
ARCANUM SCHOOL: Corporate // Enterprise Runes
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// ABAP PATTERN //
CLASS lcl_singleton DEFINITION CREATE PRIVATE.
  PUBLIC SECTION.
    CLASS-METHODS get_instance RETURNING VALUE(ro_instance) TYPE REF TO lcl_singleton.
  PRIVATE SECTION.
    CLASS-DATA go_instance TYPE REF TO lcl_singleton.
ENDCLASS.
CLASS lcl_singleton IMPLEMENTATION.
  METHOD get_instance.
    IF go_instance IS INITIAL.
      CREATE OBJECT go_instance.
    ENDIF.
    ro_instance = go_instance.
  ENDMETHOD.
ENDCLASS.

Singleton

The Singleton pattern binds the volatile entities of the ABAP runtime into a highly structured enterprise pact, ensuring safe transaction execution within the vast corporate core.

Runic Tags: #abap #singleton #enterprise #magic