Search code examples
inheritanceumlassociationsclass-diagram

Question about association classes in UML class diagram


So I need to model the situation where we have a collection of people who are members of a federation. You can either be an active member or an inactive member of the federation. If you're inactive, you're not a member of any club. If you're an active member, you are a main member to exactly one club and can have any number of clubs that you're an internal member of.

My current UML model does not enforce that every active player should have exactly one main membership so I'm wondering how I can fix this. I personally think that I can solve this by drawing a regular association between 'Main' and 'Active' but I don't really know if this is allowed or if there are any other solutions to my problem.enter image description here


Solution

  • Main is an instance of a UML Association Class because its superclass is Membership. That means Main can specialize the association (which requires another dashed line) and can subset one or both association ends. When you say

    isMemberOf { subsets isMemberOf } 1
    

    on the left end of the new association line, that means every active player must participate in exactly one Main membership, plus any number of other kinds of memberships.

    You should consider renaming the subsetting and / or subsetted properties for clarity, but UML does not require it. For example,

    isMainMemberOf { subsets isMemberOf } 1
    

    (Although that name implies a person is the Main member of a club, which is not quite right.)