The Factory Method Incantation
Delegating the instantiation of arcane constructs to specialized sigils.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Factory Method
ARCANUM SCHOOL: Conjuration // Spawning
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CLOJURE PATTERN //
(ns tekromancy.factory-method)
(defmulti summon-familiar (fn [type] type))
(defmethod summon-familiar :raven [_]
{:creature :raven, :action "Scouts the astral plane."})
(defmethod summon-familiar :shadow-cat [_]
{:creature :shadow-cat, :action "Hunts in the void."})
;; Usage:
;; (summon-familiar :shadow-cat)
Using Clojure’s multimethods, the Factory Method becomes a dynamic ritual of dispatch. By examining the essence (type) of the request, the JVM transmutation engine dynamically summons the exact familiar required, completely decoupling the invocation from the instantiation.
Runic Tags:
#creational
#factory-method
#clojure
#multimethods