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.

Figure 7-3 Points, Lines, and Squares showing methods.<br />

Chapter 7 • The Adapter Pattern 99<br />

Now, I am faced with the task of having to write the display, fill<br />

and undisplay methods for Circle. That could be a pain.<br />

Fortunately, as I scout around for an alternative (as a good coder<br />

always should), I discover that Jill down the hall has already written<br />

a class she called xxcircle that deals with circles already (see<br />

Figure 7-4). Unfortunately, she didn't ask me what she should<br />

name the methods (and I did not ask her!). She named the methods<br />

• displayIt<br />

• fillIt<br />

• undisplayIt<br />

Figure 7-4 Jill's XXCircle class.<br />

. . . but use behavior<br />

from outside

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

Saved successfully!

Ooh no, something went wrong!