Monday 3 July 2017

Software Engineering: Visitor Pattern

Behavioral Pattern - Visitor Pattern


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.

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.


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

Source code example

https://www.tutorialspoint.com/design_pattern/visitor_pattern.htm
More to follow...

No comments:

Post a Comment

Software Engineering: Bad Smells! (Smelly code)

Bad Smells! What are bad smells? This refers to any symptom in the source code of a program that possibly indicates a deeper problem.  ...