The Template Method of the Progenitor
Define the skeleton of an ancient ritual, deferring steps to specific traditions.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Template Method
ARCANUM SCHOOL: Conjuration // Ritual Frameworks
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
signature RITUAL_HOOKS = sig
val prepare : unit -> string
val finalize : unit -> string
end
functor RitualEngine(Hooks : RITUAL_HOOKS) = struct
fun executeRitual () =
( print (Hooks.prepare () ^ "\n");
print "Chanting core universal runes...\n";
print (Hooks.finalize () ^ "\n") )
end
structure NecromancyHooks : RITUAL_HOOKS = struct
fun prepare () = "Drawing a circle of bone dust."
fun finalize () = "A skeleton rises!"
end
structure PyromancyHooks : RITUAL_HOOKS = struct
fun prepare () = "Lighting the four brazers."
fun finalize () = "The flames roar with life!"
end
structure NecroRitual = RitualEngine(NecromancyHooks)
val _ = NecroRitual.executeRitual ()
The Template Method shines bright under the influence of SML’s functor system. The skeleton algorithm is encapsulated inside a functor, which takes a structure containing the specific hooks as an argument. The framework dictates the flow of the ritual, invoking the universal chants, while seamlessly deferring the localized preparations and climaxes to the provided module.
Runic Tags:
#functors
#inversion of control
#skeletons