The Flyweight
Sharing immutable aetherial essences to conserve memory dimensions.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Flyweight
ARCANUM SCHOOL: Illusion // Phantasm
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// SCHEME PATTERN //
(define rune-forge
(let ((cache '()))
(lambda (rune-type)
(let ((existing (assq rune-type cache)))
(if existing
(cdr existing)
(let ((new-rune (string-append "Rune of " (symbol->string rune-type))))
(set! cache (cons (cons rune-type new-rune) cache))
new-rune))))))
By memoizing the creation of magical essences, the flyweight pattern prevents the aether from being cluttered with redundant phantasms.
Runic Tags:
#structural
#scheme
#memoization