简体   繁体   English

公司层次结构类图

[英]Company hierarchy class diagram

I want to create an UML class diagram of a company hierarchy and I want to especially to mention that every employee has a superior in the hierarchy (for exemple every department in a company has chief and a chief is a superior of other employees in the departement ). 我想创建一个公司层次结构的UML类图,尤其要提到每个员工在层次结构中都有一个上级(例如,公司中的每个部门都有负责人,而一个负责人是部门中其他员工的上级) )。 I build this diagram but I feel that there is some thing wrong 我建立了这张图,但我觉得有些地方不对 在此处输入图片说明

I would omit every generalization, it leads to hell (imagine simple situation - you have a hospital with doctors and patients. How many instances of one person will you have, if a doctor brakes his ankle and becomes a patient? And now you decide to have a library. A doctor can borrow a book as well as a patient.). 我会忽略每一个概括,它会导致地狱(想象一个简单的情况-您有一家有医生和病人的医院。如果医生制动脚踝并成为病人,您将拥有一个人的几个实例?现在您决定有图书馆,医生和病人都可以借书。 Anyway, I would depict your domain as is at the diagram below (with example). 无论如何,我将按照下图所示(带有示例)描述您的域。

在此处输入图片说明

As for you requirement: I want especially to mention that every employee has a superior in the hierarchy. 关于您的要求:我要特别提到的是,每个员工在层次结构中都有上级。 It is not feasible in a real world. 在现实世界中这是不可行的。 So I use 0..1 multiplicity. 所以我用0..1多重性。

According to your description I'd come up with this: 根据您的描述,我想出了这个:

在此处输入图片说明

A Department is composed of Employee s. DepartmentEmployee组成。 A Chief is an Employee and there's exactly one Chief per Department . Chief是一名Employee ,每个Department只有一名Chief

There are definitely other ways to model this. 肯定还有其他方法可以对此建模。 Especially the generalization might be done in different ways. 特别是概括可以用不同的方式完成。 This depends on lots of domain details which can't be discussed here. 这取决于许多域详细信息,此处无法讨论。 But basically you could start with this approach. 但基本上您可以从这种方法开始。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM