3

Associations between classes (in class diagrams of course) are an abstraction for a set of links between different objects (in object diagrams). An aggregation is a special kind of association and it has a special symbol, the diamond.

A House has many (zero to many) windows.

enter image description here

The object names in the following diagrams should actually be underlined. My drawing aid yuml for this quick pictures has no obvious tweak for this, so I hope this is not too confusing. The only difference in both pictures is the diamond signs in the first.

my:House has side:Window
         has back:Window
         has front:Window

enter image description here

Is the diamond symbol used in object i.e. instance diagrams, too? Or are links in object diagrams always just simple lines?

enter image description here

Sled
  • 18,541
  • 27
  • 119
  • 168
panny
  • 2,186
  • 4
  • 23
  • 26

2 Answers2

4

You should use the diamond on a link as well - obviously only if the association is an aggregation.

Btw. object names (and type) should be underlined to distinguish them from classes easier.

See UML 2.4 Superstructure 7.3.22 and figure 7.52 in http://www.omg.org/spec/UML/2.4/Superstructure/PDF/

Christian
  • 13,285
  • 2
  • 32
  • 49
  • I guess my knowledge of UML in this topic was either wrong or outdated (or both!). Another round of reading the UML superstructure for me :-). Thanks @Christian for the correction. – vainolo Oct 26 '12 at 14:47
  • I cannot actually remember what vainolo suggested yesterday, but it sounded sane and more to the point to me. As for the references, I guess 7.52 is a hint to underlining. This is a technical problem with the employed software, I'm sorry for that. – panny Oct 27 '12 at 23:57
  • As for 7.3.22 I could not find a concrete suggestion as to use diamond shape or not, just a hint on using the arrows of associations. If you read something else, more in favor of using the same notation in object diagrams as in class diagrams, can you pinpoint it? – panny Oct 27 '12 at 23:59
  • 1
    A small remark: while it's ok to use diamonds in object/class diagrams, it's up to the designer to decide whether to do so according to the level of detalization he wants to achieve at the specific diagram. – SomeWittyUsername Oct 28 '12 at 06:53
  • "An instance specification is depicted using the same notation as its classifier" and "An instance specification whose classifier is an association represents a link and is shown using the same notation as for an association" lead me to that conclusion. – Christian Oct 29 '12 at 07:38
0

There is something wrong in your diagram. Because relationship between House and window should be a composition, not aggregation. If we take one specific window, that window is owned by one and only one house. If the house were to die, window will also die. So this is composition.

Answer to your question is, "we don't need to show aggregation and composition in object diagrams".

dulaj sanjaya
  • 1,290
  • 13
  • 25