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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access