Recipe19.11.Implementing the Interpreter Pattern


Recipe 19.11. Implementing the Interpreter Pattern

Problem

You want to harness the benefits of implementing the façade and interpreter patterns using AspectJ.

Solution

Unfortunately, the interpreter pattern by definition does not appear at this point to gain any design or implementation benefits from using aspect-oriented methods with AspectJ. The interpreter pattern's implementation is tied explicitly to the specific classes of the structure being interpreted; therefore, although the concept is generic, the implementation is specific and does not appear to benefit from aspect-oriented methods.

Discussion

In stating that the interpreter and the façade patterns do not benefit from AspectJ begs the question, why have they been included at all? First, it would seem odd to include some statement on all of the other GoF design patterns and just exclude these two. Second, an aspect-oriented façade in particular may prove useful. These situations are a gray area, and they benefit directly from AspectJ's ability to code weave against libraries (.jar files) and compiled code (.class files).

AspectJ can and does weave against the Java source and compiled byte code. This is useful when you wish to keep the decision whether an application contains specific aspects for a later point in a legitimate build process. However, an added feature is that you can potentially weave against legacy and third-party libraries where the source code is unavailable. This is a particularly gray area due to the legal and technical implications of changing a third party's proprietary libraries. AspectJ does provide the means by which this can be achieved if all other technical and nontechnical hurdles are overcome, although a great deal of care must be taken when this route is opted for.

See Also

Using the ajc command to compile and weave aspects into .jar libraries is shown in Recipe 2.4.



AspectJ Cookbook
Aspectj Cookbook
ISBN: 0596006543
EAN: 2147483647
Year: 2006
Pages: 203
Authors: Russ Miles

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net