我想问你关于我的班级图。我正在为我的周末大学学习制作简单门户网站的课程图。它是否正确?如果我是我的,你会改变什么?您可以在Class diagram from use case diagram找到的用例。
我应该单独创建每个用户类吗?我的意思是Admin类,Redactor类,主持人类等。我使用了特权字段(参见用户类)来模拟每个用户的角色。这是对的吗?
我认为ContentManager类包含User类实例,它在Article,Announcement,Advertisement和Comment类中用于检查是否允许这些操作。
我很高兴你的答案。在这里,您可以找到WhiteStarUML程序my XML file
的XML文件答案 0 :(得分:3)
What you should do is create an analysis model of your domain. That model would contain classes like Article
, Announcement
, etc., as you have in your current diagram. For an example, please refer to another answer I recently posted to someone else's question. The diagram for that answer is shown again here for your convenience:
Notice how the model I provided in that answer has nothing like a UserManager
or a ContentManager
that just contains code to manipulate other classes. You don't want those, unless people actually play those roles. Notice how it has verb phrases and multiplicities at the ends of every association to tell you why things are related. Notice how there are no mundane CRUD operations on those classes, like create, update, and delete.
Once you have an analysis model in place, then you should allocate actions to the appropriate classes, which will usually mirror your use cases. For example, your Comment
class might have an edit()
operation. But it might not. You might consider having an operation called replaceComment()
in the Article
class (if that's how your domain works). I don't know how your domain should work because you are missing an analysis model that teaches it to me!
After you complete an analysis model, then I would make a design model that augments it with solution-domain concerns, such as logging a user into the system. Here is an answer to another question that you may find helpful for moving from analysis to design.