Re: When and where to use Visitor Pattern?



"Ilja Preuß" <it@xxxxxxxxxxxxx> wrote in
news:426ba2dc@xxxxxxxxxxxxxxxxxxxxxxx:

>> Why make it so complicated?
>
> Decoupling. There are simply situations where you don't want to touch
> the original class when you need to change a specific operation, or
> where you even want to allow the definition of additional operations
> without having to touch them.

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.
.



Relevant Pages

  • Re: When and where to use Visitor Pattern?
    ... Sam Hwang wrote: ... Decoupling. ... original class when you need to change a specific operation, ... We'd probably don't want to have the Expression class know ...
    (comp.object)
  • Re: When and where to use Visitor Pattern?
    ... >> the original class when you need to change a specific operation, ... I consider it the most useful and powerful pattern I know. ... I've been writing a small MIDI toolkit. ... There are a lot of things you can do to with a Track class. ...
    (comp.object)

Quantcast