Linking Objects Together


When you want to show that a relationship exists between two objects, you create a link in your UML class diagram. That is, a link is the device you use in a UML diagram to indicate that two objects communicate with each other. The link appears as a line connecting two boxes representing the objects and may have a name showing somewhere along the line.

Remember Remember these characteristics of links when creating or reading a UML diagram:

  • A link relates two objects that communicate.

  • A line connecting two object boxes represents a link.

  • Naming the link is optional. We name a link only if it helps clarify what we mean to others who look at our diagrams.

So say that Safety ’R Us is a company that rents a dummy called MAX for testing. Figure 4-1 shows an object called SafetyRus (an instance of the class Client) renting MAX, an instance of the class CrashDummy—and rents is the name of the link between these two instances.

click to expand
Figure 4-1: Two linked objects.

Only when two objects are linked together can they communicate. In UML, the link notation allows the modeler to specify that SafetyRus is linked to MAX, and therefore SafetyRus can rent MAX. The link notation allows the programmer to specify that the instance SafetyRus is linked to the instance MAX, and therefore SafetyRus can invoke MAX’s operations. Still confused? Well, try looking at links like the strings on a marionette. If you want to invoke the behavior of the puppet, you must be linked to it via the strings.




UML 2 for Dummies
UML 2 For Dummies
ISBN: 0764526146
EAN: 2147483647
Year: 2006
Pages: 193

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net