The Abstract Factory
Cross-Realm Transmutation of Families of Runes
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Abstract Factory
ARCANUM SCHOOL: Transmutation // Cross-Realm
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// HAXE PATTERN //
interface ISpell {
public function cast():Void;
}
interface IWand {
public function channel():Void;
}
interface IArcaneFactory {
public function createSpell():ISpell;
public function createWand():IWand;
}
class FireSpell implements ISpell {
public function new() {}
public function cast():Void { trace("Casting Pyromancy across the planes!"); }
}
class FireWand implements IWand {
public function new() {}
public function channel():Void { trace("Channeling heat energy..."); }
}
class FireMageFactory implements IArcaneFactory {
public function new() {}
public function createSpell():ISpell { return new FireSpell(); }
public function createWand():IWand { return new FireWand(); }
}
class Client {
public static function evoke(factory:IArcaneFactory) {
var spell = factory.createSpell();
var wand = factory.createWand();
wand.channel();
spell.cast();
}
}
Through Cross-Realm Transmutation, the Abstract Factory guarantees that the runes inscribed in one plane remain compatible when ported to another. We bind spells and wands to a singular planar factory, ensuring type-safe magic regardless of the target runtime.
Runic Tags:
#transmutation
#abstract-factory
#haxe