🔮 JULIA ASTROMANCY DIFFICULTY: Adept Creational

Abstract Factory

Master the Abstract Factory pattern in Julia for complex celestial object creation.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Abstract Factory
ARCANUM SCHOOL: Conjuration // Astromancy
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// JULIA PATTERN //
# Abstract Factory in Julia utilizing Multiple Dispatch
abstract type CelestialBodyFactory end
struct StarFactory <: CelestialBodyFactory end
struct PlanetFactory <: CelestialBodyFactory end

abstract type CelestialCore end
abstract type CelestialAura end

struct PlasmaCore <: CelestialCore end
struct RockCore <: CelestialCore end
struct SolarWind <: CelestialAura end
struct Atmosphere <: CelestialAura end

# Multiple dispatch handles the creation
create_core(::StarFactory) = PlasmaCore()
create_aura(::StarFactory) = SolarWind()
create_core(::PlanetFactory) = RockCore()
create_aura(::PlanetFactory) = Atmosphere()

function invoke_creation(factory::CelestialBodyFactory)
    core = create_core(factory)
    aura = create_aura(factory)
    return (core, aura)
end

# Usage
star_factory = StarFactory()
star_core, star_aura = invoke_creation(star_factory)
Runic Tags: #creational #factory #julia #astromancy