01.01.2015 Views

UML Weekend Crash Course™ - To Parent Directory

UML Weekend Crash Course™ - To Parent Directory

UML Weekend Crash Course™ - To Parent Directory

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.

106<br />

Saturday Morning<br />

Modeling Basic Association Notations<br />

The following notations appear on almost every association you will model. Most of these<br />

elements are similar to those you find in data modeling or database design. In fact, most of<br />

the concepts come from these fields. The concepts worked well in data modeling, so they<br />

were simply brought forward into object modeling as a form of “best practices.” I suggest<br />

you memorize them because you will spend a lot of time working with them.<br />

Association name<br />

The purpose of the association can be expressed in a name, a verb or verb phrase that<br />

describes how objects of one type (class) relate to objects of another type (class). For example,<br />

a person owns a car, a person drives a car, and a person rents a car. Even though the<br />

participants are the same in each association, the purpose of each association is unique,<br />

and as such they imply different rules and interactions.<br />

<strong>To</strong> draw the <strong>UML</strong> associations for these three examples, you need to start with four basic<br />

elements.<br />

The participating classes, Person and Car. In this session I show only the name compartment<br />

so that your attention remains focused on the classes and their associations.<br />

The association, represented by a line between the two classes (pretty technical<br />

huh).<br />

The name of the association, represented by a verb or verb phrase on the association<br />

line. Don’t worry about the exact position of the name. As long as the name<br />

appears somewhere in the middle of the line, you’re okay. Just leave room at both<br />

ends of the association for all the other things you’ll learn about later in this<br />

session.<br />

The direction to read the name (indicating the direction is optional).<br />

The first two examples in Figure 10-1 read pretty much the way I described them in the<br />

text — Person owns Car and Person drives Car. Note that if these two statements are true,<br />

then the reverse would be equally true — Car is owned by Person and Car is driven by<br />

Person. Associations may be read in both directions as long as you remember to reverse the<br />

meaning of the association name from active to passive.<br />

But in the third example in Figure 10-1, the association name would not make sense if you<br />

read it in the typical left to right fashion — Car rents Person. This is a case where the direction<br />

indicator is particularly appropriate, even required, to make sense of the association by<br />

reversing the normal reading order so that it reads from right to left — Person rents Car.

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

Saved successfully!

Ooh no, something went wrong!