The Auditor Visitor
Represent an operation to be performed on the elements of an object structure without changing their classes.
β§ GANG OF FOUR LINEAGE & ARCANUM β§
GOF DESIGN PATTERN: Visitor
ARCANUM SCHOOL: Divination // Aura Reading
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// JAVASCRIPT IDIOMATIC PATTERN //
class Artifact { accept(visitor) {} }
class Sword extends Artifact {
accept(visitor) { visitor.visitSword(this); }
}
class Shield extends Artifact {
accept(visitor) { visitor.visitShield(this); }
}
class EnchantmentChecker {
visitSword(sword) { console.log("Sword aura: Sharpness +2"); }
visitShield(shield) { console.log("Shield aura: Magic Resistance"); }
}
const sword = new Sword();
const shield = new Shield();
const checker = new EnchantmentChecker();
sword.accept(checker);
shield.accept(checker);
The Auditor Visitor
When an Inquisitor inspects your armory, they donβt alter your weapons; they merely observe and react. The Visitor pattern separates an algorithm from the object structure on which it operates.
Runic Tags:
#operations
#structures
#scanning