Design Pattern improvement catalog for MixJuice

Last updated: 2002-11-18 [Single page version] [Japanese version]

We have made a catalog of design pattern improvement achieved by MixJuice language. This catalog is useful not only for MixJuice programmers, but also AspectJ, CLOS and Ruby programmers. (See the section of For other programming languages for details.)

Here is a table that shows which kind of problems of each design pattern are resolved by the basic programming techniques of MixJuice. (We recommend you read Adapter, Decorator and Visitor.)

Improvements for Design Patterns by MixJuice
Design PatternI or AResolved problemsUsed Techniques
intrextinfotypecomp
AbstractFactoryIMabst-method-add
AMMNimpl-selection
BuilderIMNmethod-add
ANimpl-selection
FactoryMethodANNimpl-selection
PrototypeIMabst-method-add
SingletonAMmethod-ext
AdapterAMMinterface-add
BridgeINabst-method-add
ANNimpl-selection
Composite
DecoratorIMmethod-add, abst-method-add
AMMclass-ext
FacadeIMnamespace-sep
Flyweight
Proxy
ChainOfResponsibilityINMmethod-add, abst-method-add
Command
InterpreterINMabst-method-add
IteratorIMnamespace-sep
Mediator
MementoIMnamespace-sep
ObserverINclass-ext
StateINabst-method-add
StrategyANimpl-selection
TemplateMethod
VisitorI1Msep-spec-impl
I2NMabst-method-add
ANabst-method-add

Meanings of abbreviations:

I or A (See the section of An improvement of the solution or another solution for details):

I
Improvement of the GoF pattern
A
Another solution to the GoF pattern

Resolved problems (See the section of Categories of resolved problems for details):

intr
Introduction problem
ext
Extensibility problem
info
Information hiding problem
type
Type safety problem
comp
Complexity problem

Whether mentioned in the GoF book or not:

M
The resolved problem is mentioned in the GoF book.
N
The resolved problem is not mentioned in the GoF book.

Used Techniques (See the page of Programming techniques of MixJuice for details):

method-ext
method extension
class-ext
class extension
interface-add
interface addition
field-add
field addition
method-add
method addition
abst-method-add
abstract method addition
impl-selection
implementation selection
namespace-sep
namespace separation
sep-spec-impl
separation of specifications and implementations

An improvement of the solution or another solution

"I" means it is an improvement of the solution. MixJuice can resolve problems of GoF patterns without changing their class structure. In this case, all merits of GoF patterns are inherited to the improved solutions.

"A" means it is another solution whose class structure is different from the corresponding GoF pattern. There may be merits and demerits compared with the original GoF pattern.

Categories of resolved problems

Introduction problem

The original GoF pattern can not be introduced to the existing program without modifying the source code.

Extensibility problem

The original GoF pattern does not support some kind of extensions without modifying the source code.

Information hiding problem

The original GoF pattern forces some names to be public. (Some of these problems can be resolved by the package/nested-class mechanisms of Java.)

Type safety problem

The original GoF pattern requires downcast to a subclass in order to invoke the methods of the subclass.

Complexity problem

The class structure of the original GoF pattern is complicated and error prone.

Layered class diagram

Each solution in this catalog is explained using a "layered class diagram" and a pseudo code of MixJuice.

Layered class diagrams express how programs are extended by difference-based modules of MixJuice.

For more details, please see the proposal of layered class diagram.

About quotations from the GoF book

This catalog contains quoations from the GoF book, "Design Patterns", Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides.

"Intent" of each design pattern are directly quoted from the GoF book.

Each class diagram has been re-written to adapt to the recent notation of UML.

For other programming languages

Many of solutions in this catalog can be applicable to other AOP(aspect-oriented programming) or open-class languages, such as AspectJ, CLOS and Ruby.

Many of the programming techniques of MixJuice have corresponding programming techniques of such languages. Here is a table that shows correspondence between techniques of MixJuice and techniques of AspectJ, CLOS and Ruby.

Languages and Techniques
TechniquesAspectJCLOSRuby
method-extaround advicealias/def
interface-adddeclare parentsdefmethodinclude
field-addintroductionassignment
method-addintroductiondefmethoddynamic method definition
abst-method-addintroductionuseless because dynamic typing
namespace-sepaspectpackage
sep-spec-impl
impl-selectionaspect selectionrequire selection

Some documents of other languages and systems explains how they make some of Design Patterns unnecessary. See the following pages.

MixJuice home page

Aspect-Oriented Design Pattern Implementations

Their programming style is quite different from ours. They do not much use introduction feature; however, we use introduction only.

Contact

Comments are welcome. Plese send mail to <akr@m17n.org>.


Akira TANAKA <akr@m17n.org>, Yuuji ICHISUGI <y-ichisugi@aist.go.jp>

Top