A Case of Visitor versus Interpreter Pattern

Mark Hills, Paul Klint, Tijs van der Storm, Jurgen J. Vinju. A Case of Visitor versus Interpreter Pattern. In Proceedings of the 49th International Conference on Objects, Models, Components and Patterns. TOOLS, 2011.


We compare the Visitor pattern with the Interpreter pattern, investigating a single case in point for the Java language. We have produced and compared two versions of an interpreter for a programming language. The first version makes use of the Visitor pattern. The second version was obtained by using an automated refactoring to transform uses of the Visitor pattern to uses of the Interpreter pattern. We compare these two nearly equivalent versions on their maintenance character- istics and execution efficiency. Using a tailored experimental research method we can highlight differences and the causes thereof. The contributions of this paper are that it isolates the choice between Visitor and Interpreter in a realistic software project and makes the difference experimentally observable.