How to associate these classes in UML Class Analysis Diagram?

梦想与她 提交于 2019-12-02 00:43:39

You have a really good start to an analysis model. Some things I would do:

  • Reify the association between User and Role (or make it an association class) called Role Assignment.
  • Add a verb-phrased property name to every end of every association. For example, Manager authorizes Role Assignment and Role Assignment authorized by Manager.

Here's an example first cut, off the top of my head:

I left off a bunch of stuff, including operations, which I would suppress for validation with SMEs. I can't do all the work for you! 😉

Short Quick Answer

Make the Role class, not the Manager class.

Long Boring Answer

I had a similar case, but, eventually, had a similar Manager class, and later add a MiddleManager class that could also manage other classes.

..........................
..+-----------------+.....
..|      User       |--+..
..+-----------------+..|..
...........^...........|..
........../ \..........|..
..........\ /..........|..
...........v...........|..Can Manage Other Users
...........|...........|..
...........|...........|..
...........|...........|..
..+-----------------+..|..
..|      Role       |--+..
..+-----------------+.....
..| [+] CanManage() |.....
..+-----------------+.....
..........................

So, I move a function or properties canManage() to the Role class.

As @Thomas Kilian mention, your question is more a behaviour feature, than a structural feature. Behaviors are represented as methods or properties, in a class diagram.

UPDATE:

..........................
..+-----------------+.....
..|      User       |--+..
..+-----------------+..|..«Can Manage Other Users»
..| [+] CanManage() |--+..
..+-----------------+.....
...........^..............
........../ \.............
..........\ /.............
...........v..............
...........|..............
...........|..............
...........|..............
..+-----------------+.....
..|      Role       |.....
..+-----------------+.....
..........................

Another version may include a self referenced association.

  1. Give the Role class some manage methods which are used for the intended purpose. But behavioral context is better shown in activity or sequence diagrams where you can elaborate what the "manage" does.
  2. Add an association from User to SwipeCard and name it "use". Further add an association from SwipeCard to Room and name it "opens".

Re 1:

these are the methods to manipulate roles and

shows how the manager uses them. The constraint tells that only the manager may use this method.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!