Reputation: 185
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.
Upvotes: 3
Views: 1122
Reputation: 13701
Although not necesarrily wrong, you might be overusing Generalization
A Generalization is a is a relationship, and where I can follow if you say
Player
is a Person
but I'm having a harder time understanding
Active
is a Player
is a Person
It seems to make more sense to model Active
or NotActive
as values of the Status
of a Player
.
Here's how the most basic model to express those requirements could look like.
Some pointers
Player
becomes a role played by Person, not the same object. So if a Player
is deleted, the Person
object can live on. In the other direction I have modelled it using compositions. So if a Person
is deleted, it's Player
role is deleted, and also it's Memberships
[0..1]
multiplicity for the main Membership. You could add a constraint there that says it's only for Memberships with property IsMainMembership = True
, and that it is mandatory for Players with Status = "Active"
Player.Status
, and the existence of a main Membership, you could also opt to make the Player.Status
derived. You could then derive the Status by checking the existence of an association to a main Membership.Active
where to become NotActive
you would have to delete the Active
object and create a new NotActive
object. Having Active/Notactive as a status would allow you to use the same object and simply change it's status. How these statusses can be changed could be modeled using a State Machine.I'm not saying this model is better or worse than your model, but it's worth think about the other end of the complexity spectrum, and where you want your model to end up at.
Upvotes: 2
Reputation: 6529
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.)
Upvotes: 1