⚔️ RPG WARD DIFFICULTY: Adept Behavioral

Template Method: The Skeletal Spell

Define the skeleton of an algorithm in an operation, deferring some steps to subclasses.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Template Method
ARCANUM SCHOOL: Necromancy // Bone
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// RPG PATTERN //
**FREE
Ctl-Opt NoMain;

Dcl-Ds TemplateHooks_t Qualified Template;
  Initialize Pointer(*Proc);
  ProcessRecord Pointer(*Proc);
  Finalize Pointer(*Proc);
End-Ds;

Dcl-Proc ExecuteBatchJob Export;
  Dcl-Pi *N;
    pHooks Pointer Value;
  End-Pi;

  Dcl-Ds Hooks Likeds(TemplateHooks_t) Based(pHooks);
  // ... define Dcl-Pr for each hook ...

  // The Template Execution
  CallInit();
  Dow Not %Eof(MyFile);
     Read MyFile;
     CallProcess();
  EndDo;
  CallFinalize();
End-Proc;

Template Method

Mainframe batch jobs usually follow a strict sequence: Initialization, The Processing Loop, and Finalization. The Template Method cements this skeleton in a generic routine, requiring developers only to provide the specific Wards for the variant steps.

Runic Tags: #behavioral #ibm-i #runes #template-method