[jdom-interest] Design Patterns - Visitor

Paul Philion philion at acmerocket.com
Wed May 2 10:38:44 PDT 2001


Frank -

I beg to differ: There are several ways to skin the Visitor, and
(personally) I try to stay away from the method you describe below.

I don't want my visited objects to implement any special interface, and I
use an implementation of the Visitor that does not require it. In my
Visitor, there are three significant actors:

- The object structure being "visited".
- A walker class that traverses the objects being visited, based on the
object structure.
- A visitor class them implements a "visit" method.

Given this structure, the walker can vary independently of the visitor,
allowing the structure to be traversed in a number of different ways, and
possibly implementing some level of filtering. The visitor class is
responsible for actually doing something with the visited object.

- Paul Philion

> -----Original Message-----
> From: jdom-interest-admin at jdom.org
> [mailto:jdom-interest-admin at jdom.org]On Behalf Of Frank Sauer
> Sent: Wednesday, May 02, 2001 1:15 PM
> To: 'jdom-interest at jdom.org'
> Subject: RE: [jdom-interest] Design Patterns
>
>
> I think you're mistaken there. All that the visitor
> pattern requires is that all objects being visited
> implement some kind of Visitable interface accepting
> a Visitor (interface) in some kind of a visit method.
> This does not require a common base class and each class
> being visited can have completely different implementations
> of the visit method. Personally I think a Visitor pattern
> could be the answer to the tree walking issues in relation to
> this common Node discussion.
>
> Frank Sauer
> The Technical Resource Connection, Inc.
> a wholly owned subsidiary of Perot Systems
> Tampa, FL
> http://www.trcinc.com
> -----------------------------------------------
> Java: The best argument for Smalltalk since C++
>
>
> -----Original Message-----
> From: Trimmer, Todd [mailto:todd.trimmer at trizetto.com]
> Sent: Wednesday, May 02, 2001 12:05 PM
> To: 'jdom-interest at jdom.org'
> Subject: [jdom-interest] Design Patterns
>
>
> More than one request to add functionality has been responded with "Use a
> Decorator for this" or "Use a Visitor for that."
>
> Both of these patterns assume a base class for a hierarchy of
> objects to be
> acted upon. Does anyone realize how much harder these patterns are to
> implement without an underlying interface? Wouldn't Node solve
> this problem?
>
>
>
> Todd Trimmer
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/yourad
dr at yourhos
t.com
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com




More information about the jdom-interest mailing list