The Prototype Hex
Cloning existing magical matrices instead of chanting from scratch.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Prototype
ARCANUM SCHOOL: Transmutation // Cloning
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// KOTLIN PATTERN //
data class SpellMatrix(val power: Int, val element: String) : Cloneable {
public override fun clone(): SpellMatrix {
return super.clone() as SpellMatrix
}
}
// Pragmatic Kotlin way
val fireBall = SpellMatrix(100, "Fire")
val greaterFireBall = fireBall.copy(power = 200)
The Prototype Hex
Why spend precious mana re-weaving a complex spell matrix when you can simply clone it? The Prototype hex allows a sorcerer to duplicate existing constructs. In the modern Kotlin paradigm, the true power of Prototype is wielded effortlessly via data classes and their inherent copy() invocation, bypassing the perilous Cloneable interface entirely.
Runic Tags:
#kotlin
#creational
#prototype