The Factory Method
Deferring instantiation to subclasses through dynamic gerund dispatch.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Factory Method
ARCANUM SCHOOL: Conjuration // Dynamic Spawning
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
create_demon =: 3 : '''Imp'''
create_angel =: 3 : '''Cherub'''
spawn_entity =: 1 : 0
entity =. u ''
'Spawned: ' , entity
)
NB. Usage:
NB. create_demon spawn_entity ''
NB. create_angel spawn_entity ''
Instead of classes, we use J’s adverbs to wrap a creation verb, delaying the binding until invocation.
Runic Tags:
#factory
#spawning
#gerunds
#operators