The Template Method Incantation
Defining the skeleton of a high ritual, deferring exact elemental steps to subclasses or downvalues.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Template Method
ARCANUM SCHOOL: Evocation // Formalism
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// MATHEMATICA PATTERN //
(* The Skeleton Ritual (Template Method) *)
ClearAll[PerformRitual, GatherComponents, Chant, Ignite];
PerformRitual[ritualType_] := Module[{},
Print["--- Commencing Ritual ---"];
GatherComponents[ritualType];
Chant[ritualType];
Ignite[ritualType];
Print["--- Ritual Complete ---"];
];
(* Default/Base behaviors if not overridden *)
GatherComponents[_] := Print["Gathering generic arcane dust."];
Chant[_] := Print["Chanting in the old tongue."];
Ignite[_] := Print["Igniting with a standard spark."];
(* Overriding for specific rituals using Pattern Matching (DownValues) *)
GatherComponents["BloodMagic"] := Print["Drawing blood from the willing vessel."];
Chant["BloodMagic"] := Print["Whispering the forbidden crimson syllables."];
GatherComponents["FrostMagic"] := Print["Collecting pure nevermelt ice."];
Ignite["FrostMagic"] := Print["Unleashing an absolute zero shockwave."];
(* Usage *)
PerformRitual["Standard"];
Print[""];
PerformRitual["BloodMagic"];
Print[""];
PerformRitual["FrostMagic"];
Runic Tags:
#template-method
#behavioral
#pattern-matching
#skeleton