Implementation

The interpreter pattern uses the composite pattern to define the internal representation of the object structure. In addition to that, it adds the implementation to interpret an expression and to convert it to the internal structure. For this reason, the interpreter pattern falls within the behavioral patterns category. The class diagram is as follows:

The interpreter pattern is composed of the following classes:

  • Context: This is used to encapsulate the information that is global to the interpreter and needs to be accessed by all concrete interpreters.
  • AbstractExpression: An abstract class or interface that declares the interpret ...

Get Design Patterns and Best Practices in Java now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.