Factory Method
Defer the exact instantiation of arcane effects to specialized subclasses of spellcraft.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Factory Method
ARCANUM SCHOOL: Conjuration // Spell Forging
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// D PATTERN //
interface ISpell { void manifest(); }
class FlameStrike : ISpell { override void manifest() {} }
class FrostNova : ISpell { override void manifest() {} }
abstract class SpellCrafter {
abstract ISpell forgeSpell();
void executeRitual() {
auto spell = forgeSpell();
spell.manifest();
}
}
class FireMage : SpellCrafter {
override ISpell forgeSpell() { return new FlameStrike(); }
}
Defer instantiation of magical artifacts to specialized elemental weavers.
Runic Tags:
#creational
#factory-method
#dlang
#polymorphism