Abstract Factory
Conjure complete families of enchanted objects and wards without binding to concrete manifestations.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Abstract Factory
ARCANUM SCHOOL: Conjuration // Elemental Arrays
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// D PATTERN //
import std.stdio;
interface ISpell { @nogc nothrow void cast(); }
interface IWard { @nogc nothrow void defend(); }
interface IMagicFactory {
ISpell createSpell();
IWard createWard();
}
class PyromancyFactory : IMagicFactory {
override ISpell createSpell() { return new Fireball(); }
override IWard createWard() { return new FlameShield(); }
}
class Fireball : ISpell {
override @nogc nothrow void cast() { /* system level invoke */ }
}
class FlameShield : IWard {
override @nogc nothrow void defend() { /* system level block */ }
}
An array of conjurations that instantiate families of related polymorphic artifacts.
Runic Tags:
#creational
#abstract-factory
#dlang
#nogc