The Adapter Conduit
Bridging incompatible magical interfaces through arcane translation.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Adapter
ARCANUM SCHOOL: Transmutation // Linguistics
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// FSHARP PATTERN //
// The ancient, incompatible system
type AncientRuneReader() =
member _.ReadRune(runeId: int) =
sprintf "Deciphering ancient rune #%d" runeId
// The modern interface required by the guild
type IModernScrollScanner =
abstract member ScanScroll: string -> string
// The Adapter
type RuneToScrollAdapter(reader: AncientRuneReader) =
interface IModernScrollScanner with
member _.ScanScroll(scrollName: string) =
// Translating modern scroll names to ancient rune IDs
let mockId = scrollName.Length
reader.ReadRune(mockId)
let ancientDevice = AncientRuneReader()
let scanner : IModernScrollScanner = RuneToScrollAdapter(ancientDevice)
printfn "%s" (scanner.ScanScroll("Scroll of Fireball"))
When old world ancient devices must be hooked into the modern .NET functional wards, an Adapter bridges the disparate realities, hiding the translation within its core.
Runic Tags:
#structural
#adapter
#fsharp
#conduits