🟨 JAVASCRIPT PATTERN DIFFICULTY: Adept Behavioral

The Ritual Template Method

Define the skeleton of a ritual in an operation, deferring some steps to subclasses.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Template Method
ARCANUM SCHOOL: Necromancy // Ritual Crafting
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// JAVASCRIPT IDIOMATIC PATTERN //
class RitualSkeleton {
  performRitual() {
    this.prepareCircle();
    this.chant();
    this.manifest();
  }
  prepareCircle() { console.log("Drawing salt circle."); }
  chant() { throw new Error("Must implement chant"); }
  manifest() { console.log("The entity appears!"); }
}

class DemonSummoning extends RitualSkeleton {
  chant() { console.log("Chanting abyssal verses."); }
}

class SpiritSummoning extends RitualSkeleton {
  chant() { console.log("Singing ancestral songs."); }
}

const ritual = new DemonSummoning();
ritual.performRitual();

The Ritual Template Method

Every summoning ritual follows the same basic cadence: prepare, chant, and manifest. But the exact words vary. The Template Method cements the structure while leaving the specifics to specialized sub-rituals.

Runic Tags: #templates #rituals #inheritance