The Abstract Factory
Conjuring related mystic artifacts through minimalist parenthetical runes.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Abstract Factory
ARCANUM SCHOOL: Conjuration // Artifice
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// SCHEME PATTERN //
(define (make-mage-factory)
(lambda (msg)
(case msg
((create-wand) (lambda () 'mage-wand))
((create-robe) (lambda () 'mage-robe)))))
(define (make-warlock-factory)
(lambda (msg)
(case msg
((create-wand) (lambda () 'warlock-staff))
((create-robe) (lambda () 'warlock-cloak)))))
(define (summon-equipment factory)
(let ((wand ((factory 'create-wand)))
(robe ((factory 'create-robe))))
(list wand robe)))
In the minimalist parenthetical runes of Scheme, abstract factories are simply closures returning closures.
Runic Tags:
#creational
#scheme
#closures
#runes