Supporting Visitor

Chapter 5, Composite, introduced the MachineComponent hierarchy and suggested several possible behaviors for this composite structure. Suppose that the developers at Oozinoz have built some of these behaviors into the hierarchy and have also applied VISITOR to allow for later extensions. Figure 29.1 shows the current state of the hierarchy.

Figure 29.1. The MachineComponent hierarchy designers planned for extension by building in support for visitors.

The figure doesn't explain how VISITOR works; the next section does that. The figure simply shows some of the groundwork that lets you apply VISITOR.

One aspect of allowing for ...

Get Design Patterns Java™ Workbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.