Summary

Interpreters let you compose new commands, using the classes in a hierarchy that you create. Each class in the hierarchy defines a way of composing commands—a grammar rule. This composition rule determines how the class implements, or interprets, an operation that you distribute throughout the hierarchy.

The operation in an interpreter is often named execute() or evaluate(). The operation name is necessarily vague, becoming meaningful only when combined with the name of the class that implements it. Like STATE, STRATEGY, and COMMAND, the INTERPRETER pattern fixes the name of an operation and uses various classes to implement the operation. INTERPRETER applies this idea to let you compose executable objects according to a set of composition ...

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.