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.

3O8 Part V1 • Endings and Beginnings<br />

The next step in<br />

commonality/<br />

variability analysis<br />

But please keep learning patterns. Read the literature. <strong>Patterns</strong> provide<br />

the backdrop for discussions about lessons learned in analysis<br />

and design. They give a team of developers a common vocabulary<br />

for discussing a problem. They enable you to incorporate<br />

best-practice approaches into your code.<br />

Decomposing a Problem Domain<br />

into Responsibilities<br />

Commonality/variability analysis identifies my conceptual view<br />

(the commonality) and my implementation view (each particular<br />

variation). If I consider just the commonalities and the objects that<br />

use them, I can think about the problems in a different way— a<br />

decomposition of responsibilities.<br />

In the Bridge pattern, for example, the pattern says to look at my<br />

problem domain as being composed of two different types of entities<br />

(abstractions and implementations). I therefore do not need to be<br />

limited by just doing object-oriented decomposition (that is, decomposing<br />

my problem domain into objects), I can also try decomposing<br />

my problem domain into responsibilities, if that is easier for me to<br />

do. I can then define the obje cts that I require to implement these<br />

responsibilities (ending up with object decomposition).<br />

This is just an extension of the rule I stated earlier that designers<br />

should not worry about how to instantiate objects until after they<br />

know all of the objects they need. That rule can be viewed as a<br />

decomposing the problem domain into two parts:<br />

• Which objects are needed<br />

• How these objects are instantiated<br />

Specific patterns often give us assistance in thinking about how to<br />

decompose responsibilities. For example, the Decorator pattern<br />

gives me a way to combine objects flexibly if I decompose my prob-

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

Saved successfully!

Ooh no, something went wrong!