Re: When and where to use Visitor Pattern?
- From: "Ilja Preuß" <it@xxxxxxxxxxxxx>
- Date: Sun, 24 Apr 2005 15:45:03 +0200
Sam Hwang wrote:
> 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.
In your example, what if I wanted to display the expression in a Swing UI?
In a Web UI? SWT? We'd probably don't want to have the Expression class know
about all those - that would violate the Single Responsibility Principle.
Visitor is a good match in that situation.
See http://www.butunclebob.com/ArticleS.UncleBob.IuseVisitor
Hope this helps, Ilja
.
- Follow-Ups:
- Re: When and where to use Visitor Pattern?
- From: paul campbell
- Re: When and where to use Visitor Pattern?
- From: Rich MacDonald
- Re: When and where to use Visitor Pattern?
- References:
- When and where to use Visitor Pattern?
- From: Sam Hwang
- When and where to use Visitor Pattern?
- Prev by Date: Re: author of this article?
- Next by Date: Re: author of this article?
- Previous by thread: Re: When and where to use Visitor Pattern?
- Next by thread: Re: When and where to use Visitor Pattern?
- Index(es):