This article describes the Interpreter design pattern. This is a behavioral design pattern, a category of design pattern used by software engineers, when writing computer programs.

Tablefragment-inner">

Introduction

The Interpreter pattern is a design pattern, used in software engineering, to identify meaning to symbols, words or sentances in a language. Computer languages use interpreters and databases use them to evaluate database queries. each symbol or token represents a class, and the relationship between these classes defines the syntax of the language. The Interpreter uses the syntax and grammar to interpret the language.

It is defined as a behavioral design pattern, because program execution can be affected by what is interpreted.

Benefits

The obvious benefit is a unified language that separate systems can share, or a human interface that performs complex operations based on simple keywords.
The logic that constrains an application is exposed through the language, and provides a testable interface of input parameters.

Examples of the pattern

In it's simplest form, an interpreter can be the processor for a naming convention. For example, knowing how to split a filename into chunks and acting on the file depending on the parts of the filename, like storing into a "Sales" database, or processing the file as an ".xml" file.

Another example would be a function to translate of decimal to hex. It takes in the decimal value, then looks up the literal representation of the value and returns the hex equivalent. To do this, it must know the sequence of characters that represent each value, and how they build up from bits to bytes. These rules are the grammar behind the language.

 

Return to Top


See Also

Link to domain parent articles and related articles in TechNet Wiki.

 

 

Return to Top


Community Resources

These are the external links, including links to Microsoft and TechNet sites that are non-Wiki

 

 

 

Return to Top


References section

Use this section if you pulled source material and ideas from other sites, blogs, or forums. Make sure you have permission from authors to use their material.

 

 

 

Return to Top