Intent
Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates.
Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates.
Why is this used?
Handy for recovering lost type information. Allow you to add operations to a Composite structure without changing the structure itself. Also, adding new operations is relatively easy. Furthermore, the code operations performed by the Visitor is centralised.
Handy for recovering lost type information. Allow you to add operations to a Composite structure without changing the structure itself. Also, adding new operations is relatively easy. Furthermore, the code operations performed by the Visitor is centralised.
UML diagram representation
https://www.tutorialspoint.com/design_pattern/images/visitor_pattern_uml_diagram.jpg
Visual representation
http://www.vincehuston.org/images/visitor_taxi.gif
https://www.tutorialspoint.com/design_pattern/images/visitor_pattern_uml_diagram.jpg
Visual representation
http://www.vincehuston.org/images/visitor_taxi.gif
Source code example
https://www.tutorialspoint.com/design_pattern/visitor_pattern.htm
More to follow...
No comments:
Post a Comment