Re: When and where to use Visitor Pattern?



"Rich MacDonald" <rich@@clevercaboose.com> wrote in message
news:Xns9644C928CC626richclevercaboosecom@xxxxxxxxxxxxxxx
> "Ilja Preuß" <it@xxxxxxxxxxxxx> wrote in
> news:426ba2dc@xxxxxxxxxxxxxxxxxxxxxxx:
>
> Or the fact that that original class(es) needs to "do a hundred things".
> Rather than add all that stuff into the class and create a mess, you keep
> it lean and delegate off to a hundred visitors.
>
> Done well, I consider it the most useful and powerful pattern I know.

I think it's fair to point out, though, that this sentiment is not
universal, see for example http://nice.sourceforge.net/visitor.html. To the
extent that the vistor pattern is just a poor man's substitute for
multimethods, wouldn't "instanceof" do just as well? And be a little
clearer? With less clutter in the core class (no visit method)?

Regards,
Daniel Parker


.


Quantcast