12.07.2015 Views

DEV475 Mastering Object-Oriented Analysis and Design with UML ...

DEV475 Mastering Object-Oriented Analysis and Design with UML ...

DEV475 Mastering Object-Oriented Analysis and Design with UML ...

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>DEV475</strong> <strong>Mastering</strong> <strong>Object</strong>-<strong>Oriented</strong> <strong>Analysis</strong> <strong>and</strong> <strong>Design</strong> <strong>with</strong> <strong>UML</strong>Example: Multiple AssociationsExample: Multiple AssociationsScheduleprimaryCoursesCourseOfferingalternateCoursesScheduleadd student toremove student fromCourseOfferingMultiple associations must reflect multiple roles.<strong>Mastering</strong> <strong>Object</strong> <strong>Oriented</strong> <strong>Analysis</strong> <strong>and</strong> <strong>Design</strong> <strong>with</strong> <strong>UML</strong>Copyright © 2003 Rational Software, all rights reserved 50There can be multiple associations between the same two classes, but they shouldrepresent distinct relationships, <strong>and</strong> DIFFERENT ROLES; they should not be just forinvoking different operations.If there is more than one association between two classes then they MUST be named.It is unusual to find more than one association between the same two classes.Occurrences of multiple associations should be carefully examined.To determine if multiple associations are appropriate, look at instances of the classes.ClassA <strong>and</strong> ClassB have two associations between them, Assoc1 <strong>and</strong> Assoc2. If aninstance of ClassA has a link <strong>with</strong> two SEPARATE instances of ClassB, then multipleassociations are valid.In the above example, the top diagram is an appropriate use of multiple associations,but the bottom diagram is not. In the valid case, two associations are requiredbetween Schedule <strong>and</strong> CourseOffering, as a Schedule can contain two kind ofCourseOfferings, primary <strong>and</strong> alternate. These must be distinguishable, so twoseparate associations are used. In the invalid case, the two relationships representtwo operations of CourseOffering, not two roles of CourseOffering.Remember, Students <strong>and</strong> CourseOfferings are related via the Schedule class. Studentsare enrolled in a CourseOffering if there is a relationship between the Student’sSchedule <strong>and</strong> the CourseOffering.6 - 50

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

Saved successfully!

Ooh no, something went wrong!