✨ ARCANUM RUNE DIFFICULTY: Adept Structural

The Decorator

Dynamically attaching new enchantments to existing magical constructs.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Decorator
ARCANUM SCHOOL: Enchantment // Modification
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
interface Weapon {
  strike(): string;
}

class CyberBlade implements Weapon {
  strike() { return "Slashing with monomolecular edge."; }
}

abstract class WeaponEnchantment implements Weapon {
  constructor(protected weapon: Weapon) {}
  abstract strike(): string;
}

class VenomRune extends WeaponEnchantment {
  strike() {
    return `${this.weapon.strike()} ..also inflicts digital venom!`;
  }
}

The Decorator pattern attaches additional responsibilities to an object dynamically. It provides a flexible alternative to subclassing for extending functionality—perfect for stacking endless auras, runes, and enchantments onto a baseline artifact without polluting the core class.

Runic Tags: #structural #typescript #decorator