Re: When and where to use Visitor Pattern?



paul campbell wrote:

> Yes the visitor is great at decoupling. Its especially good at
> "decoupling" all that useful positional context information that is
> essential to just about
> every graph traversal problem Ive ever encoutered :).

- Visitor is also very usefull for non-graphs (that is, single objects).
- In my experience, there actually are graph traversal problems that don't
need positional context information, or can be transformed to one that
doesn't.
- For some problems, the Visitor pattern actually is quite easy to extend so
that it takes positional context information into account.
- Nevertheless there are certainly graph traversal problems for which
Visitor isn't the best solution. That doesn't make it a useless pattern, of
course.

Cheers, Ilja


.