In OOAD, how should i represent the property that the entity is shared with multiple users with different permissions?

41 views Asked by At

I am developing a feature where i have an entity which represents a view. The entity holds the attributes as things what to display in view, name and other stuffs. These can be justified as attributes of the entity as it is tightly coupled with it. When it comes to the use case that the entity i.e the view is shared with multiple other users with different permission levels, since this not being tightly coupled with the entity should i place it inside the entity as a attribute or manage it separately from the entity.

I am new to OOAD and i tried to get the use case down and jot down the nouns as classes. Verbs as methods and stuff. So it would be better if you could throw some light on what should be done in such case could help me.

Use Case Diagramm

enter image description here

Class Diagramm enter image description here

1

There are 1 answers

0
Martin Frank On

there are multiple permissions checks to be performed when working with views:

  • is the user allowed to open a (shared) view
  • is the user allowed to edit a view
  • is the user allowed to share a view

so the permission is not only part of the share a view to others use case but used in (many) other use cases as well.

this assertion reveals, that the permission is needed as separate aspect of your application. so yes, you should put your permission in a separate class.

Code snippets:

#1: public void editView(View view, User user, Share.Permission permission)

vs.

#2: public void editView(View view, User user, Permission permission)

in example #1 you have to know about

  • view/user
  • Share
  • and you have to know that Share has a Permission

in example #2 you simply have to know about

  • view/user
  • a permission