The Bridge Matrix
Decoupling a magical abstraction from its elemental implementation.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Bridge
ARCANUM SCHOOL: Transmutation // Matrix
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// FSHARP PATTERN //
type IElementalSource =
abstract member Channel: unit -> string
type FireSource() =
interface IElementalSource with
member _.Channel() = "Flames roar!"
type FrostSource() =
interface IElementalSource with
member _.Channel() = "Ice crackles!"
[<AbstractClass>]
type Spell(source: IElementalSource) =
member _.Source = source
abstract member Cast: unit -> unit
type EvocationSpell(source: IElementalSource) =
inherit Spell(source)
override this.Cast() =
printfn "Casting evocation: %s" (this.Source.Channel())
let fireEvocation = EvocationSpell(FireSource())
fireEvocation.Cast()
The Bridge pattern allows the abstraction of spell-casting to vary independently from the raw elemental source it taps into. This dual-hierarchy system prevents the proliferation of classes like FireEvocation, FrostEvocation, and so forth.
Runic Tags:
#structural
#bridge
#fsharp
#elemental