The Template Method Skeleton
Define the unyielding skeleton of a grand ritual, letting apprentices fill in the specific elemental steps.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Template Method
ARCANUM SCHOOL: Evocation // Rituals
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// SCALA PATTERN //
abstract class GrandRitual {
// The Template Method
final def perform(): Unit = {
drawCircle()
chant()
ignite()
}
private def drawCircle(): Unit = println("Drawing salt circle...")
// Steps to be implemented by subclasses
def chant(): Unit
def ignite(): Unit
}
class FireRitual extends GrandRitual {
def chant(): Unit = println("Chanting the words of ember.")
def ignite(): Unit = println("Flames erupt!")
}
Inversion of Control. The base GrandRitual calls the subclass’s implementations, ensuring the dangerous sequence of the ritual cannot be reordered by a novice.
Runic Tags:
#scala
#behavioral
#ritual-structure