How would you use UML to model multiple relationships between the same two classes?

John Moore

 

 

One way to show this is to simply use multiplicity on the relationship – an employee is "has" one or two addresses, as shown in the following class diagram:

But if it is important to show that one address is temporary and one is permanent, then a better way to model this would be to use two separate relationships with rolenames, as indicated below.

This second diagram would correspond more closely to the following code fragment:

public class Employee
  {
    private Address permanantAddress;
    private Address temporaryAddress;

    //...
  }

Note that this second approach is practical only when the maximum multiplicity is small.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact