25 Interpreter
AS WITH THE COMMAND pattern, the INTERPRETER pattern produces an executable object. The patterns differ in that INTERPRETER involves the creation of a class hierarchy in which each class implements, or interprets, a common operation in a way that matches the class’s name. In this regard, INTERPRETER is similar to the STATE and STRATEGY patterns. In INTERPRETER, STATE, and STRATEGY, a common operation appears throughout a collection of classes, with each class implementing the operation in a different way.
The INTERPRETER pattern is also similar to the COMPOSITE pattern, which defines a common interface for individual items and groups of items. COMPOSITE does not require different, interesting ways of forming groups, although ...
Get Design Patterns in Java™, Second Edition 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.