|
|
Hi Bruce,
I am a great fan of all your work.
I learnt Java from you and it helped pay my rent.
Now I'm learning Python, maybe it'll pay my mortgage :).
Anyway, my question is on the Visitor pattern example.
You mention that the Flower hierarchy cannot change,
then how come you can add a method accept(Visitor)?
The way I am thinking of implementing Visitor/Visited, is have a corresponding visited hierarchy, VisitedFlower (decorator), which in turn has an accept(Visitor) method.
The Visitor methods remains the same visit(Flower1), visit(Flower2)..... VisitedFlower's accept method, will call
visitor.visit(decorated), where decorated is the Flower object.
Do you think my reasoning is correct?
Thanks much.
AMI
|
|