Reputation: 753
Assuming everyone has the rights to do the CRUD operations (everyone is an admin type user). I have displayed CRUD operations the user can perform in the Domain diagram however, it's become quite messy. I am curious if it's acceptable to do the alternative approach shown in the images below instead since the multiplicative relationships remain the same for each action (create,edit,delete)
Upvotes: 1
Views: 614
Reputation: 5673
The main issue with both of your class models is a confusion between the type/instance levels. Your "can create/edit/delete" authorization relationships do not hold between a specific user and a specific object (an instance of Company
, Project
or Ticket
), but rather between a specific user and a sepcific object type (Company
, Project
or Ticket
), so it's not an ordinary association between two ordinary object types.
If you want to describe/define such authorization relationships with a class model, you would need to define a meta-class like ObjectType
and express that your object types (Company
, Project
or Ticket
) are instances of it.
Upvotes: 2
Reputation: 73587
If it becomes messy, it probably lacks of separation of concerns, or represents associations that are not really needed.
Are the associations needed?
An association between User
and Xxx
implies a semantic relationship between the two classes. This means that instances of the classes are linked and not just for the time of an operations. So x
would be able to find the User
(s) that updated it, and u
would know the Xxx
instances that it updated. This kind of association can make sense if you want some audit trails, but this seems not to be your purpose here.
In other words, the fact that a User
may perform some operations that CRUD instances of Xxx
is not sufficient for justifying an association.
If they are needed, do they represent what you think?
Now it appears that your associations are can ...
, i.e. some kind of authorisation scheme. Your diagram tells that each user would need to know in advance all the Xxx
that it could update. This is a heavy burden. It would also imply that a user needs to know all the Xxx
it can create; before they are even created? This looks somewhat inconsistent.
Modeling an authorisation scheme
If you'd wand to design an authorisation system, you'd probably not link users directly to the object, but use some intermediary mechanisms:
Separation of concerns
And to keep things continue to be messy, you should consider:
Upvotes: 2