The Bridge
Decoupling an abstraction from its implementation so both can vary independently.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Bridge
ARCANUM SCHOOL: Transmutation // Synthesis
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
interface SpellEffect {
ignite(): string;
}
class PlasmaEffect implements SpellEffect {
ignite() { return "Igniting super-heated plasma!"; }
}
abstract class Wand {
protected effect: SpellEffect;
constructor(effect: SpellEffect) {
this.effect = effect;
}
abstract wave(): string;
}
class ChromiumWand extends Wand {
wave() {
return `Chromium Wand shines: ${this.effect.ignite()}`;
}
}
The Bridge pattern decouples an abstraction from its implementation. By splitting the magic focus (the Wand) from the elemental result (the SpellEffect), mages can pair any material conduit with any energy signature without creating an exponential number of specific wand classes.
Runic Tags:
#structural
#typescript
#bridge