The Builder
Assembling complex arcane constructs piece by piece via tail-call recursion.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Builder
ARCANUM SCHOOL: Conjuration // Golemancy
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// SCHEME PATTERN //
(define (make-golem-builder)
(let ((head #f) (body #f) (limbs '()))
(define (dispatch msg . args)
(case msg
((set-head!) (set! head (car args)))
((set-body!) (set! body (car args)))
((add-limb!) (set! limbs (cons (car args) limbs)))
((build) (list 'golem head body limbs))))
dispatch))
(define (construct-golem builder)
(builder 'set-head! 'obsidian-skull)
(builder 'set-body! 'clay-torso)
(builder 'add-limb! 'runic-arm)
(builder 'add-limb! 'runic-arm)
(builder 'build))
The builder pattern emerges naturally from message-passing closures that accumulate internal state until invoked to yield the final construct.
Runic Tags:
#creational
#scheme
#state
#runes