The Factory Method
Define an interface for creating a magical entity, but let the subclasses decide which entity to instantiate.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Factory Method
ARCANUM SCHOOL: Conjuration // Summoning
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
unique type Familiar = Imp | Sprite | Raven
ability Summoning where
manifest : () -> Familiar
spriteSummoner : '{Summoning} a -> a
spriteSummoner f =
h : Request Summoning a -> a
h = cases
{Summoning.manifest _ -> resume} -> handle resume Sprite with h
{a} -> a
handle !f with h
impSummoner : '{Summoning} a -> a
impSummoner f =
h : Request Summoning a -> a
h = cases
{Summoning.manifest _ -> resume} -> handle resume Imp with h
{a} -> a
handle !f with h
Instead of relying on rigid polymorphic classes, the Unison mage uses Abilities to defer the exact nature of the conjuration. The Factory Method is a handled effect: the core spell simply requests a manifest, and the enclosing ritual space (the handler) dictates the specific manifestation.
Runic Tags:
#creational
#factory-method
#unison
#abilities