23.07.2012 Views

Design Patterns Explained

Design Patterns Explained

Design Patterns Explained

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

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

Thus, the Bridge pattern creates the context for the Adapter pattern.<br />

I can eliminate the Adapter pattern as a candidate for senior-most<br />

pattern.<br />

The relationship between context and used by.<br />

Often, it seems that when one pattern uses another pattern, the<br />

pattern that is used is within the context of the pattern doing the<br />

using. There are likely exceptions to this rule, but it seems to<br />

hold most of the time.<br />

Now I only have to compare Bridge-Facade and Facade-Adapter.<br />

I will look at the Bridge and Facade relationship first because if the<br />

Bridge turns out to be the primary pattern there as well, I do not<br />

need to consider the Adapter-Facade relationship (remember, I am<br />

only trying to identify the seniormost pattern at this point).<br />

It should be readily apparent that the same logic that applied to<br />

Bridge and Adapter also applies to Bridge and Facade:<br />

• I will be using the Facade pattern to simplify the V1 system's<br />

interface.<br />

• But what will be using the new interface I create? One of the<br />

implementations of the Bridge pattern.<br />

Therefore, the Bridge pattern creates the context for the Facade.<br />

The Bridge is the seniormost pattern.<br />

According to Alexander, I am supposed to start with the whole.<br />

Going back to the beginning, I find that I do not yet have the context<br />

for the Bridge.<br />

One down, two to go<br />

The Bridge-Facade<br />

relationship<br />

The Bridge is the<br />

winner

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

Saved successfully!

Ooh no, something went wrong!