The Visitor drops by:
- The Visitor must visit each element of the Composite; that functionality is in a Traverser object.
- The Visitor is guided by the Traverser to gather state from all of the objects in the Composite.
- Once the state has been gathered, the Client can have the Visitor perform various operations on the state.
- When new functionality is required, only the Visitor must be enhanced.
From: Head First Design Patterns.
1. https://github.com/devwebcl/simple_design_patterns/tree/master/visitor-pattern/src/main/java/com/iluwatar/visitor
2. https://github.com/devwebcl/simple_design_patterns/tree/master/visitor-pattern/src/main/java/com/behavioural/visitor
References:
- https://github.com/chirey/designPatternsThoughtsCode
- https://github.com/iluwatar/java-design-patterns/tree/master/visitor
No comments :
Post a Comment