O'Reilly logo

Design Patterns Java™ Workbook by Steven John Metsker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required