Saturday 17 March 2007

Lecture 5: Visitor Patterns

The lecture this week had to be cut short because our lecturer was feeling under the weather, hopefully she gets better soon.
We did manage to look at the visitors pattern in greater detail from when we looked at it yesterday. It became apparent that some thought is required before the visitor pattern is implemented as it is a trade off between adding additional functionality and increase the number of classes in an application. It appears that the visitor pattern cuts down the work of the designer and developer because implementing this pattern requires the addition of new behaviours in one place, the visitor class. Our lecturer also gave an excellent example of when a visitor could be used injunction with an iterator.
The java world website shows a good example on how to cut out a huge list of if-else statements by implementing the visitor pattern while iterating through a collection.

No comments: