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