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.

32 Part I • An Introduction to Object-Oriented Software Development<br />

Different ways of<br />

showing class<br />

information<br />

There are variations on these themes. For example, to say something<br />

contains something else can mean that<br />

• The contained item is a part of the containing item (like an<br />

engine in a car).<br />

• I have a collection of things that can exist on their own (like<br />

airplanes at an airport).<br />

The first example is called composition while the second is called<br />

aggregation. 1<br />

Figure 2-1 illustrates several important things. First, each rectangle<br />

represents a class. In the UML, I can represent up to three things in a<br />

class:<br />

• The name of the class<br />

• The data members of the class<br />

• The methods (functions) of the class<br />

Figure 2-1 The Class Diagram — its three variations.<br />

I have three different ways of showing these.<br />

• The leftmost rectangle shows just the class' name. I would use this<br />

type of class representation when more detailed information is<br />

not needed.<br />

1. Gamma, Helm, Johnson, and Vlissides (the Gang of Four) call the first "aggrega tion"<br />

and the second "composition"— exactly the reverse of the UML. However, the<br />

Gang of Four book was written before the UML was finalized. The presented<br />

definition is, in fact, consistent with the UML's. This illustrates some of the motivation<br />

for the UML; before it came out there were several different modeling languages,<br />

each with its own notation and terms.

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

Saved successfully!

Ooh no, something went wrong!