Visitor

E173622

Visitor is a behavioral design pattern that lets you separate algorithms from the objects on which they operate by allowing new operations to be defined without changing the classes of the elements they act on.

All labels observed (1)

Label Occurrences
Visitor canonical 3

How this entity was disambiguated

Statements (48)

Predicate Object
instanceOf behavioral design pattern ⓘ
design pattern ⓘ
advantage adds new operations without modifying element classes ⓘ
groups related operations in a single visitor class ⓘ
makes adding new operations easy ⓘ
supports different behaviors over the same object structure ⓘ
alsoKnownAs Visitor pattern ⓘ
applicableWhen object structure contains many distinct classes with different interfaces ⓘ
object structure is relatively stable ⓘ
operations over object structure are frequently changed or added ⓘ
belongsTo Gang of Four design patterns ⓘ
category object-oriented design pattern ⓘ
collaboratesWith Composite pattern ⓘ
Interpreter pattern ⓘ
Iterator pattern ⓘ
commonLanguages C# ⓘ
C++ ⓘ
Java ⓘ
Python ⓘ
commonUseCase operations over XML or JSON document trees ⓘ
operations over file system directory trees ⓘ
syntax tree processing in compilers and interpreters ⓘ
definedIn Design Patterns: Elements of Reusable Object-Oriented Software ⓘ
disadvantage can break encapsulation by exposing element internals ⓘ
increases coupling between visitors and element classes ⓘ
makes adding new element classes harder ⓘ
enables double dispatch ⓘ
keyMethod accept operation on Element ⓘ
visit operation on Visitor ⓘ
originLanguage C++ ⓘ
primaryIntent allow new operations to be defined without changing element classes ⓘ
separate algorithms from the objects on which they operate ⓘ
relatedTo Command pattern ⓘ
linked to: Command

Composite pattern ⓘ
Strategy pattern ⓘ
structure Visitor interface declares visit methods for each concrete element type ⓘ
each element class implements an accept(Visitor) method ⓘ
supports open/closed principle ⓘ
typicalParticipants ConcreteElement ⓘ
ConcreteVisitor ⓘ
Element interface ⓘ
ObjectStructure ⓘ
Visitor interface ⓘ
usedFor accumulating results over object structures ⓘ
adding new operations to object structures without modifying their classes ⓘ
implementing double dispatch ⓘ
performing operations over complex object structures ⓘ
traversing composite object structures ⓘ

How these facts were elicited

Referenced by (3)

Full triples — surface form annotated when it differs from this entity's canonical label.