Design Patterns (GoF) (50 Qs)•Part 3: Architectural Patterns & Enterprise Systems (25 - 35)
What is the Visitor Pattern and how does it add new operations without modifying existing classes?
junior Leveldesign-patternsArchitectural Patterns
In Simple Words:
The Visitor Pattern uses Double Dispatch (element.accept(visitor) -> visitor.visit(element)) to separate an algorithm from the object structure on which it operates, allowing new operations to be added without modifying the element classes.