Chapter 25. Interpreter

The interpreter pattern, like the STATE and STRATEGY patterns, distributes an operation across a collection of classes. In such patterns, the effect of calling the operation depends on the class of the object that receives the call. In both STATE and STRATEGY, the receiver of an operation call is a single object. INTERPRETER takes the same idea and applies it to a composition—in particular, a rich composite, or one with various ways of forming groups.

The INTERPRETER pattern is similar to the COMPOSITE pattern, which defines a common interface for individual items and groups of items. COMPOSITE does not require various, interesting ways of forming groups, although it allows this. For example, the ProcessComponent hierarchy ...

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.