The Factory Method: Spawning the Logical Node
Define an interface for creating a single node, but let subclasses alter the type.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Factory Method
ARCANUM SCHOOL: Conjuration // Node-Weaving
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// ALLOY PATTERN //
abstract sig NodeConstruct {}
sig DataNode, LogicNode extends NodeConstruct {}
abstract sig NodeSpawner {
spawns: one NodeConstruct
}
sig DataSpawner extends NodeSpawner {}
{
spawns in DataNode
}
sig LogicSpawner extends NodeSpawner {}
{
spawns in LogicNode
}
pred spawn_logic[s: LogicSpawner] {
some s.spawns
}
run spawn_logic for 3
The Factory Method: Spawning the Logical Node
The simplest form of creation magic in Alloy. The Spawner simply decrees that its spawns relation must yield a specific subset of the NodeConstruct hierarchy. Through these declarations, the model-finder explores only valid permutations of node genesis.
Runic Tags:
#creational
#factory method
#sigils