Frage

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

Keine korrekte Lösung

Andere Tipps

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top