The Template Method
Defining the skeleton of an incantation, deferring specific steps to subclasses.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Template Method
ARCANUM SCHOOL: Evocation // Ritual Structure
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
abstract class RitualCasting {
// The Template Method
public performRitual(): void {
this.drawCircle();
this.chant();
this.releaseEnergy();
}
private drawCircle(): void {
console.log("Drawing binding circle of chalk and salt.");
}
protected abstract chant(): void;
protected abstract releaseEnergy(): void;
}
class DemonSummoning extends RitualCasting {
protected chant(): void { console.log("Chanting abyssal verses."); }
protected releaseEnergy(): void { console.log("Tearing a rift to the void!"); }
}
The Template Method pattern defines the skeleton of an algorithm in an operation, deferring some steps to subclasses. It ensures the fundamental structure of a magic ritual—like drawing a circle before chanting—is invariant, while allowing specific traditions to implement their own dark verses and manifestations.
Runic Tags:
#behavioral
#typescript
#template-method