❌ HAXE TRANSMUTATION DIFFICULTY: Apprentice Creational

The Factory Method

Delegating arcane materialization to subclasses

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Factory Method
ARCANUM SCHOOL: Conjuration // Materialization
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// HAXE PATTERN //
interface IPortal {
    public function open():Void;
}

class NetherPortal implements IPortal {
    public function new() {}
    public function open():Void { trace("Opening a gateway to the Nether planes."); }
}

class AstralPortal implements IPortal {
    public function new() {}
    public function open():Void { trace("Piercing the veil to the Astral realm."); }
}

abstract class PortalCrafter {
    public function new() {}

    // The Factory Method
    public abstract function createPortal():IPortal;

    public function trigger():Void {
        var portal = createPortal();
        trace("Reticulating planar splines...");
        portal.open();
    }
}

class NetherCrafter extends PortalCrafter {
    public function createPortal():IPortal {
        return new NetherPortal();
    }
}

class AstralCrafter extends PortalCrafter {
    public function createPortal():IPortal {
        return new AstralPortal();
    }
}

When the exact plane of existence isn’t known until compilation time, the Factory Method delays materialization to the subclasses. It acts as an anchor for cross-realm targets, ensuring that each target environment can supply its own portal implementation without altering the core ritual.

Runic Tags: #conjuration #factory-method #haxe