The Visitor: The External Inspector
Represent an operation to be performed on the elements of an object structure.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Visitor
ARCANUM SCHOOL: Divination // Structure-Inspection
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// ALLOY PATTERN //
abstract sig MatrixNode {
accept: one Probe
}
sig DataBank, LogicGate extends MatrixNode {}
abstract sig Probe {
scannedNodes: set MatrixNode
}
sig DiagnosticsProbe extends Probe {}
fact "Probes Scan What Accepts Them" {
all n: MatrixNode, p: n.accept | n in p.scannedNodes
}
run {} for 3
The Visitor: The External Inspector
When navigating a complex MatrixNode tree, it is safer to externalize the operation. The Probe acts as the visitor. We enforce the pattern mathematically: if a node accepts a probe, it must irrevocably belong to that probe’s scannedNodes set, ensuring complete diagnostic coverage.
Runic Tags:
#behavioral
#visitor
#diagnostics