An Interpreter Example

The robots that Oozinoz uses to move material along a processing line come with an interpreter that controls the robot and that has limited control of machines on the line. The interpreter comes as a hierarchy of classes that encapsulate robot commands. At the head of the hierarchy is an abstract Command class. Distributed across the hierarchy is an execute() operation. The interpreter performs the same role as an API (application programming interface) but lets you create new machine programs at runtime. Figure 25.1 shows the commands that the robot interpreter supports.

Figure 25.1. An interpreter hierarchy provides for runtime programming of a factory robot.

The interpreter hierarchy includes commands that let you start ...

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.