[jdom-interest] Visitor (was: API Inertia)

Paul Jakubik pauljakubik at yahoo.com
Wed May 2 13:58:30 PDT 2001

See comments below.

--- Joseph Bowbeer <jozart at csi.com> wrote:
> Elliotte Rusty Harold writes
> > Why don't the visit methods return the values
> requested
> > instead of void? Why the extra level of
> indirection?
> I was wondering this myself as I was cutting and
> pasting my own example from
> a previous message.  It would make my example
> easier.  Another question I
> had was whether Visitor should be an interface and
> DefaultVisitor would be
> the default implementation.  These are all possible
> tweaks, I think.

The Visitor pattern does not normally return an
object, and that does not represent an unnecessary
extra level of indirection--it is indirection that is
critical for Visitor to be a useful pattern. The
entity that calls the visit methods is not the entity
that cares about the object that could be returned.
Remember that visiting is generally used for visiting
collections and complex structures, so one visitor
object will visit many objects after the user calls a
single accept method.

More information about the jdom-interest mailing list