0

Having a class Customer that has a list of up to 10 Orders:

Customer
--------
+orders:Order[0..10]

But that means Customer is associated with Order class via aggregation, also:

Customer                                          Order
--------                <>------------------->    --------
+orders:Order[0..10]

Should I also indicate 0-10 in the class association? Because I saw many diagrams do but on the other hand, this is specified in the attribute of Customer.

John V
  • 4,855
  • 15
  • 39
  • 63
  • No arrays doesn't accept unknown(dynamic) length, because of their nature(at least in Java and C#, not in C/C++), you need to specify the length with association. –  Nov 02 '13 at 20:13

1 Answers1

1

In fact you have to choose how you want to show the fact that a customer has a list of up to 10 Orders. You can depict it as an attribute or an aggregation or both but this latest option could be confusing. In all case if you want to model that as association (or composition or aggreagation) you have to show the multiplicity otherwise it would not be clear...

For more information take look a the 9.5.3 section of UML 2.5 specification

Red Beard
  • 3,436
  • 1
  • 14
  • 17
  • Well so if I get it correctly, I can either show class diagrams with associations between classes (but with no attribues/operations) OR classes with attribues/operations but no associations – John V Oct 31 '13 at 09:13
  • In fact you can show it as an attribute or an association or both. UML do not provide rule you have to choice each time and you can mix as you want. The only thing is you decide to represent, for example the fact that your class Customer has a list of up to 10 Orders, as an attribute AND an association this could be confusing... – Red Beard Oct 31 '13 at 11:51
  • But when doing class diagram, I think it is quite common to have both attributes/operations and class relations. How would you model that? Association without multiplicity? I mean if you need to show complete diagram, one just cannot skip associations – John V Oct 31 '13 at 12:21
  • I agree, you should depict attributes, operations and class association. But in order to model that a class Customer that has a list of up to 10 Orders you have to CHOOSE between depict it as an attribute OR an association with its multiplicity. I would not depict as an attribute AND an association even if it is not formally forbidden. – Red Beard Oct 31 '13 at 12:30
  • Thanks, I am pretty new to this. How would you do that then, with both attributes and associations? If this was a part of much larger diagram – John V Oct 31 '13 at 12:33
  • How I would do what? represent the same information as an attribute and an association? I would not ... – Red Beard Oct 31 '13 at 12:43
  • I see, so could I omit this attribute but keep the others? – John V Oct 31 '13 at 12:52
  • Instead of omit it, you will show it as an association, right? – Red Beard Oct 31 '13 at 12:57