Search code examples
umldiagramclass-diagram

UML Class Diagram - Modelling with Enumeration


In a UML class diagram, how would I model a tutor can work multiple days of the week without knowing specifically? In my current solution: 1 or more tutors work on 1 or more days of the week.

enter image description here


Solution

  • Since the list of days when Tutor work is only an attribute and doesn't seem to have any specific structure to build a class around it, it should rather be an inline attribute with type DaysOfTheWeek and multiplicity 1..7 . Also since you can't work twice at the same day you should add unique constraint. Your argument (within the class Tutor ) should look like that:

             -workingDays : DaysOfTheWeek [1..7] {unique}
    

    The multiplicity on Tutor side in your diagram suggests you have at least one Tutor for each possible working day (enumeration value). If this is true you can add this as a class constraint then. For traceability reasons you can add dependency (dashed line with open arrow) from Tutor to DaysOfTheWeek , but that's not necessary.

    If you have a reason to build a dedicated class, your diagram can look like this

    Class version diagram

    I'm sorry, for some reason my tool doesn't export the stereotype even though I've placed it. DaysOfTheWeek should have the Enumeration but it was lost in the export.

    A general side remark: a class has to have a name. It can't be just a stereotype.