Question

The visitor pattern is depicted in LePus3 as shown in the picture below.

How does this diagram relate to the corresponding (Java) source code of the visitor pattern?

How do the artefacts in the diagram (client, Member, Ops, Elements, Aggregate, Visitors, square, triangle etc.) manifest themselves in the source code of the visitor pattern ?

enter image description here

No correct solution

OTHER TIPS

You can use code example from Wikipedia, where:

Class VisitorDemo is the Client rectangle.

Classes Wheel, Engine, Body, Car is elements triangle, and ICarElement is their abstract parent with void accept(ICarElementVisitor visitor); as Accept (abstract Visitor) oval.

Classes CarElementPrintVisitor, CarElementDoVisitor are at the same time Ops oval and Visitors triangle with

void visit(Wheel wheel);
void visit(Engine engine);
void visit(Body body);
void visit(Car car);

as Visit oval.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top