⚔️ RPG WARD DIFFICULTY: Apprentice Creational

Factory Method: The Spawning Rune

Define an interface for creating a Ward, but let subclasses decide which class to instantiate.

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

// A service program exporting a factory rune
Dcl-Proc CreateDocument Export;
  Dcl-Pi *N Pointer;
    DocType Char(10) Const;
  End-Pi;

  Select;
    When DocType = 'INVOICE';
      Return CreateInvoiceRune();
    When DocType = 'PO';
      Return CreatePORune();
    Other;
      Return *Null;
  EndSl;
End-Proc;

Factory Method

A common technique among iSeries Wards, the Factory Method delegates the instantiation of specific Business Logic Runes (like handling an Invoice or a Purchase Order) based on the inputs to a generalized Service Program method.

Runic Tags: #creational #ibm-i #runes #factory