Search code examples
umlassociationsdiagramclass-diagram

Representing associations between a class and itself


I have a class Tutor and there are some instances of that class can be course coordinators, can I represent the relationship using recursive association? this is how I represented the association at first, which I think is not correct

enter image description here


Solution

  • Quick fix

    In your diagram you claim that all Tutors are coordinating exactly a single Course. It's the consequence of 1 being the same as 1..1. But this is not what your narrative says:

    some instances of that class can be course coordinators.

    You should therefore replace the multiplicity on the Course side with 0..1. It which would translate some Tutors can be coordinating a Course (but not all).

    Another alternative

    The inconvenience is that the model does not define Course Coordinators. Maybe it's just the wording and doesn't matter. But may be there is more about Course Coordinator that would justify a separate class with additional properties and behaviors:

    • If it's a special kind of Tutor, just make it a specialization thereof, and let this additional class have the coordinating association.

    • If this is a special role that a Tutor but also other classes (Professor, Assitant, ...) could take, you'd better prefer composition over inheritance (object composition in OOP corresponds to UML associations). The association between Tutor and Course Coordinator would read "have the role of".

    Not related:

    A couple of additional questions for you (just to ensure that the multiplicities say what you meant):

    • One specific Course could be taught by several Tutors ?
    • No Tutor could teach more than one Course ?
    • A specific Course could have no Tutor for teaching (because * means 0..*)?
    • The same Course could be coordinated by several Tutors?