19.2. UML
This Unified Modified Language (UML) diagram details a class design using the Visitor Design Pattern (see Figure 19-1). Note the following about this diagram:
The MyObject class can be visited. It is the base class. It has one public method called acceptVisitor(). This method accepts a parameter called Visitor. Internally, the acceptVisitor() class calls the public method visit() from the Visitor parameter object that it is passed. It passes in an instance of itself.
The MyVisitor class is the Visitor in this diagram. All Visitors are required to have the public method visit(). This method accepts an instance of MyObject. The visit() method may call additional logic, such as the protected doSomething() method. This is the unique portion of the visiting class.
Figure 19-1. Figure 19-1
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access