Linking Objects Together

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 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: 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.

 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows