Aggregation multiplicity UML
Asked Answered
A

2

8

In aggregation, does the diamond shape side have a multiplicity of 1 maximum, or can it be 0..* ? Or is it depending of a point of view ?

Analyze answered 18/12, 2012 at 14:31 Comment(0)
H
5

Firstly, you need to be specific about which 'diamond' you mean as a empty diamond in aggregation and a filled diamond is composition?

If you mean empty diamond then Icepack is correct, and you are confusing 2 separate things. Multiplicity is not related to Aggregation so a 'diamond shaped' aggregation indicator can have any multiplicity you like as they are unrelated.

If you mean filled diamond ie composition then the example someone has posted won't really help you as it's saying: "There are many departments but only 1 University (multiplicity)" and that "if all departments are deleted then University is also deleted (composition)".

I am struggling to think of a good example where composition end wouldn't be 1 only and as far as I can think it would never be 0..* as you can have a class which has to delete something which may not ever exist? I could however be 1..* ie many to many, for example Exam and Exam Questions.

The multiplicity may be 1..* to 1..* ie exam have 1 or more question and a question can reside in 1 or more exams. Filled diamond (composition) at Exam end would mean that if all questions were deleted then all exams would be deleted too

Hulbard answered 26/9, 2013 at 15:38 Comment(0)
F
3

Yes, it can be 0..*. There is a good example here: Department has several professors and each professor may belong to several departments at the same time.

Fluor answered 18/12, 2012 at 15:24 Comment(7)
@sfinnie you're welcome to use any means you like to represent this kind of relation. I don't know any better wayFluor
it's a straight binary. The hollow diamond tells you nothing that a straight binary wouldn't. It's just visual noise.Unkennel
But don't take my word for it: read this question (#9641385) to see what Jim Rumbaugh, UML co-author, has to say about it.Unkennel
don't see any contradiction. aggregation adds details. it's up to you to decide whether you need these details or not. besides, aggregation isn't the issue here but multiplicity of a specific side in the relation. the answer is the same for simple associationFluor
Didn't say there was contradiction. I said there was confusion. The fact the original question was asked attests to that. My point was (is) that UML aggregation, as currently defined, is rarely a useful concept. As for adding "details", depends what you mean by "detail". The only well-defined semantic it adds is recursive acyclicity. Otherwise it doesn't say anything a straight binary doesn't. And very few people know the acyclic property. So you have to point it out explicitly anyway. [ctd]Unkennel
Of course, you may have your own conventions for using aggregation: so when you see an aggregation instead of a binary you think "Ah, ok, this has special property xx". And that's fine, the language is there to be used. I've found it just causes confusion - so don't use it. YMMV. I suspect we're getting well off topic for the OP now though...Unkennel
@Unkennel I see aggregation and composition as further specializations of association. At a later stage of design each association becomes either association or composition. I mainly use aggregation relation to manifest that it's not composition (and composition in the similar manner). If it's not important for the specific diagram, I omit it. But indeed, it's way off topic...Fluor

© 2022 - 2024 — McMap. All rights reserved.