Re: When and where to use Visitor Pattern?
- From: "H. S. Lahman" <h.lahman@xxxxxxxxxxx>
- Date: Sat, 23 Apr 2005 16:15:58 GMT
Responding to Hwang...
Why make it so complicated? Can't we use this one instead? class IntExp1 extends Expression
<snip> I dont know in what cirumstances the pattern is used sensablely. I hope someone can address my confusion. Thanks!
Visitor addresses a very complex dynamic accessing problem where there is a combinatorial number of direct relationships between subclasses of two trees:
[A]
A
|
+--------+-------+--...
| | |
[B] [C] [D]...
[W] [X] [Y]
| | |
+--------+-------+---....
|
-
V
[Z]where every subclass of [A] can have a direct 1:1 relationship to every subclass of [Z]. Similarly, every subclass of [Z] can have a direct 1:1 relationship with every subclass of [A]. IOW, there is a combinatorial set of 1:1 relationships between all the subclasses of each relationship. Since those relationships are between subclasses, the specializations are being accessed, which means each relationship must access a unique set of properties. Just to make things a bit worse, the particular relationship being navigated needs to be dynamically determined based upon run-time context.
That gets to be very messy if there are a lot of subclasses. Visitor offers a very elegant way to handle that in a cookbook fashion. OTOH, if not /all/ of those factors are relevant, then Visitor becomes overkill.
************* There is nothing wrong with me that could not be cured by a capful of Drano.
H. S. Lahman hsl@xxxxxxxxxxxxxxxxx Pathfinder Solutions -- Put MDA to Work http://www.pathfindermda.com blog: http://pathfinderpeople.blogs.com/hslahman (888)OOA-PATH
.
- References:
- When and where to use Visitor Pattern?
- From: Sam Hwang
- When and where to use Visitor Pattern?
- Prev by Date: Re: audit log on normalized data
- Next by Date: Re: Objective criticism of inheritance
- Previous by thread: Re: When and where to use Visitor Pattern?
- Next by thread: Re: When and where to use Visitor Pattern?
- Index(es):
Relevant Pages
|