-1

Can anyone direct me to an excellent article that describe the visitor design pattern, provided that the code is written in Java.

Thanks

3 Answers 3

5

Google is your friend.

http://www.javaworld.com/javatips/jw-javatip98.html: And usually JavaWorld has good stuff

http://en.wikipedia.org/wiki/Visitor_pattern#Java_example: And even the wikipedia entry has a Java example that you're probably looking for.

3
  • thanks for the pdf link & to the javaworld article they are really helpful
    – skystar7
    Nov 29, 2010 at 23:59
  • Hi The www.patterndepot.com site seems to have been permanently taken down! The set of pdfs related to the gof design patters (under www.patterndepot.com/put/8/*) was excellent. Any ideas if this content has been replicated elsewhere? Thanks in advance
    – user584973
    Jan 21, 2011 at 21:04
  • Perhaps try getting it via the wayback machine: archive.org/web/web.php
    – digiarnie
    Jan 21, 2011 at 22:27
2

You can find an excellent description of visitor pattern in "Refactoring to Patterns" of Joshua Kerievsky.
The example given in it makes everything clear. The book is not freely available though.

1
  • thank you, but unfortunately i don't have the book
    – skystar7
    Nov 30, 2010 at 0:00
0

I've researched a lot in the Internet about this pattern. I've learned that there are several flavors of this pattern.

In particular, I've seen so many confused implementations which I decided to think more about it and design something which I could consider acceptable for my purposes.

I work with a large and complex library in Java which extensively uses the Visitor Pattern in a very clean and neat way. In particular, I don't like implementations with visitA, visitB, visitWhatever, acceptA, acceptB, acceptWhatever. This is absolutely wrong, IMHO. You don't need this. If you keep everything neat, you can have concerns separated on their respective classes and your life will be much happier.

If you have a chance, please have a look at an article I've written about this.

Cheers

Not the answer you're looking for? Browse other questions tagged or ask your own question.