✨ GLEAM ALCHEMY DIFFICULTY: Apprentice Creational

The Factory Method

Type-safe conjuration via opaque types and constructor functions.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Factory Method
ARCANUM SCHOOL: Conjuration // Entity Spawning
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// GLEAM PATTERN //
pub opaque type Golem {
  Golem(power: Int, material: String)
}

pub fn animate_clay_golem() -> Golem {
  Golem(power: 5, material: "Clay")
}

pub fn animate_iron_golem() -> Golem {
  Golem(power: 20, material: "Iron")
}

The Factory Method

Opaque types combined with constructor functions provide the exact semantics of a factory method while preserving type-safe encapsulation.

Runic Tags: #conjuration #factory-method #gleam