⚔️ RPG WARD DIFFICULTY: Apprentice Behavioral

Strategy: The Tactical Rune

Define a family of algorithms, encapsulate each one, and make them interchangeable.

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

Dcl-Proc CalculateTotal Export;
  Dcl-Pi *N Packed(15:5);
    BaseAmount Packed(15:5) Const;
    pPricingStrategy Pointer(*Proc) Value;
  End-Pi;

  Dcl-Pr ApplyStrategy Packed(15:5) ExtProc(pPricingStrategy);
    Amount Packed(15:5) Const;
  End-Pr;

  Return ApplyStrategy(BaseAmount);
End-Proc;

Strategy

The Strategy pattern provides a framework for injecting logic directly into the flow of a program. Rather than hard-coding business rules for holiday discounts or volume pricing, the overarching Service Program merely calls whatever tactical pricing rune is passed to it.

Runic Tags: #behavioral #ibm-i #runes #strategy