The Bridge Hex
Decoupling a magical abstraction from its elemental implementation.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Bridge
ARCANUM SCHOOL: Illusion // Construct
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// KOTLIN PATTERN //
interface Enchantment {
fun applyEffect()
}
class FireEnchantment : Enchantment {
override fun applyEffect() = println(" engulfed in flames!")
}
abstract class Weapon(protected val enchantment: Enchantment) {
abstract fun swing()
}
class Sword(enchantment: Enchantment) : Weapon(enchantment) {
override fun swing() {
print("Swinging sword...")
enchantment.applyEffect()
}
}
The Bridge Hex
When crafting weapons and enchantments, an explosion of permutations can crash the compile-time matrix. The Bridge Hex separates the abstraction (the weapon) from the implementation (the enchantment), allowing them to evolve independently. This compositional rune keeps our armory flexible and our codebases clean.
Runic Tags:
#kotlin
#structural
#bridge