23.07.2012 Views

Design Patterns Explained

Design Patterns Explained

Design Patterns Explained

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 12 • Solving the CAD/CAM Problem with <strong>Patterns</strong> 2O3<br />

Start with (and<br />

When I am considering which pattern creates context for the others, I<br />

reject) Abstract<br />

begin with Abstract Factory. The Abstract Factory's context is<br />

Factory<br />

determined by the objects it needs to instantiate, as shown by the<br />

following:<br />

• There will be a set of make methods, the implementation of<br />

each having a return new xxx in it.<br />

• At this time, I do not know what xxx will be.<br />

• xxx will be determined by the objects I am using.<br />

• The objects that I will need to use are defined by other patterns.<br />

Since I cannot even define the Abstract Factory until I know the<br />

classes the other patterns will define, it is not the seniormost pattern<br />

(the pattern that creates the context for the other patterns).<br />

Therefore, I reject it for now as the pattern to start working on.<br />

In fact, the Abstract Factory will be the last pattern I do (unless<br />

another creational pattern shows up during my initial design, in<br />

which case, both creational patterns will vie for being last).<br />

Seniormost patterns constrain the other patterns.<br />

Seniormost is my term for the one or two patterns that establish a<br />

context for the other patterns in my system. This is the pattern<br />

that constrains what the other patterns can do. Other terms you<br />

could use are outermost patterns or context-setting patterns.<br />

There are three pairs of patterns left to consider: Three pairs left<br />

• Adapter-Bridge<br />

• Bridge-Facade<br />

• Facade-Adapter

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!