CSC/ECE 517 Fall 2012/ch2b 2w51 aa: Difference between revisions
No edit summary |
|||
Line 2: | Line 2: | ||
In Object Oriented Programming, visitor pattern is a way of decoupling algorithms to be performed by an object. The way to do this is create a visitor class which would help to add new virtual function to the classes without modifying their structures. This is accomplished by creating appropriate specializations of the virtual function in visitor class which will take instance reference as input and implements the algorithm using double dispatch. | In Object Oriented Programming, visitor pattern is a way of decoupling algorithms to be performed by an object. The way to do this is create a visitor class which would help to add new virtual function to the classes without modifying their structures. This is accomplished by creating appropriate specializations of the virtual function in visitor class which will take instance reference as input and implements the algorithm using double dispatch. | ||
* http://kasunpanorama.blogspot.com/2010/04/understanding-visitor-pattern.html | * http://kasunpanorama.blogspot.com/2010/04/understanding-visitor-pattern.html This page can provide more introductory information on visitor pattern | ||
==Motivation== | ==Motivation== |
Revision as of 04:45, 19 November 2012
Introduction
In Object Oriented Programming, visitor pattern is a way of decoupling algorithms to be performed by an object. The way to do this is create a visitor class which would help to add new virtual function to the classes without modifying their structures. This is accomplished by creating appropriate specializations of the virtual function in visitor class which will take instance reference as input and implements the algorithm using double dispatch.
- http://kasunpanorama.blogspot.com/2010/04/understanding-visitor-pattern.html This page can provide more introductory information on visitor pattern
Motivation
- http://en.wikipedia.org/wiki/Visitor_pattern - Motivation for visitor patterns is nicely depicted in Wikipedia for Visitor pattern.
- http://www.oodesign.com/visitor-pattern.html - One of the top visited sites for design pattern basics to implementation, oodesign.com has good introduction, implementation details.
- http://sourcemaking.com/design_patterns/visitor This page has good detailed description of visitor pattern and the worth reading part is the discussion section of this page which also talks about how double dispatch is related to visitor.
- http://www.dofactory.com/Patterns/PatternVisitor.aspx - Simple introductory page which describes and talks about the pattern in short.
Visitor Pattern in Java
(1) http://java.dzone.com/articles/design-patterns-visitor (2) http://www.javaworld.com/javatips/jw-javatip98.html (3) http://snehaprashant.blogspot.com/2009/01/visitor-pattern-in-java.html (4) http://en.wikipedia.org/wiki/Visitor_pattern#Java_example
Visitor Pattern in C++
Following are the links which provides examples based on C++:
- This page explains visitor pattern in detail from the basics upto implementation using C++ as language. It has implementation details and also have discussed issues that arise. http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.defaultroles.c++.html
Visitor Pattern in Python
Following are two links which provide good examples of implementation of visitor patterns in python:
Visitor Pattern in Ruby
(1) https://gist.github.com/989193 (2) http://www.scribd.com/doc/2217773/Design-Patterns-in-Ruby
Advantages
- This links helps to understand the advantage of a design pattern like visitor, which are the features it combines and how it makes it easy for programmer to implement those ideas. http://compilers.cs.ucla.edu/jtb/jtb-2003/whyvisitors/whyvisitors.html
- The applicability of visitor pattern can be found here: http://www.swe.uni-linz.ac.at/research/deco/designPatterns/visitor/visitor.abstract.html#Applicability
Disadvantages
- This page has a subsection in the visitor pattern section which discusses issues related to visitor pattern. http://www.developerfusion.com/article/84939/iterators-composites-and-visitors/
Video Lecture:
(1) https://www.youtube.com/watch?v=mTJodk3vfdk
(2) https://www.youtube.com/watch?v=UYUopyMcWjw&feature=related