Visitor: The Wandering Sage
Represent an operation to be performed on the elements of an object structure.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Visitor
ARCANUM SCHOOL: Conjuration // Teleportation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// RPG PATTERN //
**FREE
Ctl-Opt NoMain;
Dcl-Ds Element_t Qualified Template;
Type Char(10);
Data Pointer;
End-Ds;
Dcl-Proc AcceptVisitor Export;
Dcl-Pi *N;
pElement Pointer Value;
pVisitorLogic Pointer(*Proc) Value;
End-Pi;
Dcl-Ds Elem Likeds(Element_t) Based(pElement);
Dcl-Pr Visit ExtProc(pVisitorLogic);
pElem Pointer Value;
End-Pr;
Visit(pElement);
End-Proc;
Visitor
When dealing with a complex Data Structure representing differing record types, adding new operations can muddy the entities. The Visitor pattern abstracts the operation away, acting as a Wandering Sage that traverses the structure and performs logic on each element externally.
Runic Tags:
#behavioral
#ibm-i
#runes
#visitor