🟣 KOTLIN HEXES DIFFICULTY: Adept Behavioral

The Template Method Hex

Defining the skeleton of a ritual while deferring the specifics.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Template Method
ARCANUM SCHOOL: Evocation // Ritual
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// KOTLIN PATTERN //
abstract class Ritual {
    fun performRitual() {
        prepareAltar()
        chant()
        ignite()
    }

    private fun prepareAltar() = println("Cleaning altar.")
    abstract fun chant()
    private fun ignite() = println("Lighting candles.")
}

class FireRitual : Ritual() {
    override fun chant() = println("Chanting words of flame.")
}

The Template Method Hex

Rituals demand a precise sequence of events. The Template Method Hex defines the skeletal structure of an algorithm in a base class, sealing the order of operations, while allowing subclasses to override specific magical steps. It enforces architectural discipline while permitting localized creativity.

Runic Tags: #kotlin #behavioral #template-method