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>Association or Aggregation?Association or Aggregation?• If two objects are tightly bound by a whole-partrelationship• The relationship is an aggregation.CarDoor10..2,4• If two objects are usually considered asindependent, although they are often linked• The relationship is an association.CarDoor10..2,4When in doubt use association<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 46Aggregation should be used only where the "parts" are incomplete outside the contextof the whole. If the classes can have independent identity outside the contextprovided by other classes, or if they are not parts of some greater whole, then theassociation relationship should be used.When in doubt, an association is more appropriate. Aggregations are generallyobvious. A good aggregate should be a natural, coherent part of the model. Themeaning of aggregates should be simple to underst<strong>and</strong> from the context. Choosingaggregation is only done to help clarify; it is not something that is crucial to thesuccess of the modeling effort.The use of aggregation versus association is dependent on the application you aredeveloping. For example, if you are modeling a car dealership, the relationshipbetween a car <strong>and</strong> the doors might be modeled as aggregation, because the caralways comes <strong>with</strong> doors, <strong>and</strong> doors are never sold separately. However, if you aremodeling a car parts store, you might model the relationship as an association, as thecar (the body) might be independent of the doors.6 - 46

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

Saved successfully!

Ooh no, something went wrong!