Visitor Design Pattern

The design pattern provides additional functionality to a class. The Visitor pattern allows us to create an external class to act on data in other classes.

Visitor Design Pattern

Visitor Design Pattern

       

  1. Visitor Design Pattern
    The design pattern provides additional functionality to a class. The Visitor pattern allows us to create an external class to act on data in other classes. This is useful in those conditions if a fair number of instances are available of small number of classes and we have to perform some operations on all or on most of those classes.

    Lets take an example that demonstrates that how the classes implement the Visitor interface. In the following example we are taking the two interfaces one is Visitor interface and the other is Colddrink interface and then we implement to these interfaces into our classes.

Read more at:

http://www.javajazzup.com/issue9/page38.shtml