CHAPTER 7 ■ WHAT ARE DESIGN PATTERNS? WHY USE THEM?
128
ME: I’m thinking of using a Composite.
B
OB: I don’t think you’ve thought that through.
OK, Bob didn’t agree with me. He never does. But he knew what I was talking about, and therefore
why my idea sucked. Let’s play that scene through again without a design vocabulary.
M
E: I intend to use a tree of objects that share the same type. The type’s
interface will provide methods for adding child objects of its own type. In this
way, we can build up complex combinations of implementing objects at
runtime.
B
OB: Huh?
Patterns, or the techniques they describe, tend to interoperate. The Composite pattern lends itself to
collaboration with Visitor:
M
E: And then we can use Visitors to summarize the ...