The Abstract Factory: Aetheric Forging
Forge families of related alchemical artifacts without specifying their exact material compositions.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Abstract Factory
ARCANUM SCHOOL: Transmutation // Aetheric Forging
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// BLAZING-FAST ZIG ALCHEMY //
const std = @import("std");
pub const Relic = struct {
power: u32,
vtable: *const VTable,
pub const VTable = struct {
ignite: *const fn (self: *Relic) void,
};
pub fn ignite(self: *Relic) void {
self.vtable.ignite(self);
}
};
pub const RelicForge = struct {
vtable: *const VTable,
pub const VTable = struct {
createStaff: *const fn (self: *RelicForge, allocator: std.mem.Allocator) !*Relic,
createOrb: *const fn (self: *RelicForge, allocator: std.mem.Allocator) !*Relic,
};
pub fn createStaff(self: *RelicForge, allocator: std.mem.Allocator) !*Relic {
return self.vtable.createStaff(self, allocator);
}
pub fn createOrb(self: *RelicForge, allocator: std.mem.Allocator) !*Relic {
return self.vtable.createOrb(self, allocator);
}
};
In the deepest layers of the syntactical abyss, the Abstract Factory stands as the High Forge. It allows modern alchemists to instantiate families of arcane artifacts—Staves and Orbs of specific elemental typings—without committing to concrete transmutation sequences. Explicit aether allocation ensures no rogue mana bleeds into the void.
Runic Tags:
#abstract-factory
#creational
#zig
#alchemy