1

I have made this simple UML diagram.

Simple UML V2

I want to have a list of treatments inside class Customer.

My question is if I need another association to make this possible.

Geert Bellekens
  • 12,788
  • 2
  • 23
  • 50
troviç
  • 21
  • 3
  • If this is supposed to be a class diagram, then I do not understand why `Treatment` is associated with `Menu` and not with `Customer`. Also, the arrows are inheritance relationships. Why do`Treatment` and `Customer` inherit from `Menu`? – Turing85 May 09 '21 at 16:32
  • Hello, You are right.. I used the wrong arrows. I've updated my UML and added an aggregation. However I'm still not sure if this is correct. I appreciate any tips and/or feedback. Troviç – troviç May 09 '21 at 18:29
  • Have a look at association classes. – qwerty_so May 09 '21 at 19:06

1 Answers1

1

A class diagram describes classes and not objects. A TreatmentList is a TreatmentList, regardless if you look at it from the Menu or the Customer persepective.

So indeed, if you want a list of treatment "inside" the class Customer, you'll need just to add another association between the classes you want to connect.

Now I wonder if you did not try to design user interface using a class diagram:

  • Main -> Menu -> List 1 or List 2 looks terribly like a flow in the user interface, more than a set of related classes. You don't need this. And lass diagrams are not meant for this purpose. If you want to model an UI Menu, you'd model a menu class, i.e a general class that could instantiate any kind of menus, with a one-to-many association with MenuAction. Perhaps ShowTreamtmentList would be a specialization of such an action.
  • The TreatmentList and CustomerList only make sense if these are classes, i.e. they could be instantiated into one or several objects that each represent a different list. If, for an association, you'd have a multiplicity of * on the side of customer or treatment, you would not need to add a special list/set/bag in the middle.
  • You don't need to use an aggregate instead of an association. Aggregate are not very uselful and appear to be overused. Prefer a simple association.
Christophe
  • 68,716
  • 7
  • 72
  • 138