#211 added further examples for structural and behavioral patterns

This commit is contained in:
Narendra Pathai
2016-08-20 20:49:28 +05:30
parent c79df708b1
commit a0c77c32b5
11 changed files with 47 additions and 7 deletions

View File

@ -4,7 +4,7 @@ title: Interpreter
folder: interpreter
permalink: /patterns/interpreter/
categories: Behavioral
tags:
tags:
- Java
- Gang Of Four
- Difficulty-Intermediate
@ -25,6 +25,13 @@ trees. The Interpreter pattern works best when
* the grammar is simple. For complex grammars, the class hierarchy for the grammar becomes large and unmanageable. Tools such as parser generators are a better alternative in such cases. They can interpret expressions without building abstract syntax trees, which can save space and possibly time
* efficiency is not a critical concern. The most efficient interpreters are usually not implemented by interpreting parse trees directly but by first translating them into another form. For example, regular expressions are often transformed into state machines. But even then, the translator can be implemented by the Interpreter pattern, so the pattern is still applicable
## Real World Applications
* [java.util.Pattern](http://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html)
* [java.text.Normalizer](http://docs.oracle.com/javase/8/docs/api/java/text/Normalizer.html)
* All subclasses of [java.text.Format](http://docs.oracle.com/javase/8/docs/api/java/text/Format.html)
* [javax.el.ELResolver](http://docs.oracle.com/javaee/7/api/javax/el/ELResolver.html)
## Credits
* [Design Patterns: Elements of Reusable Object-Oriented Software](http://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612)