I have been struggling to get my system into a class diagram. I tend to make relationship mistakes by thinking too much in database structure. I have a class diagram:
So to explain the situation I need:
The employee part:
The project part:
To explain what the system must do:
An employee can be assigned to a certain phase of a project. The project should be of a certain type and that type consists of certain project phases. The project phase is a certain phase.
Because an employee needs to see all of his current projects etc I made a link to employee and project too. I don't know if this is correct or that it is the project phase it's responsibility to provide the right project to the employee.
As a rule of thumb - there is no such thing as the only correct method of drawing diagram.
An obvious mistake is your usage of composite aggregation. With such usage you assume that a ProjectPhase is attached to one Employee and cannot be shared with other Employees and definitely that's not what you want to depict here.
If you want to show that the project is build of several employees, you could eventually use shared aggregation which means you should have an opposite direction and an open diamond.
In case of ProjectPhase and ProjectType this is a composite aggregation but in opposite direction (ProjectType is build of specific ProjectPhases and a ProjectPhase is a part of exactly one ProjectType).
Project to ProjectType and Phase to ProjectPhase are places where several options exist.
If you assume that a Project is build of Phases and then you want to model specific types of Projects (eg ProjectWaterfall, ProjectScrum, ProjectXP, ProjectRUP, ProjectPrince2) which will specialise the Project having specific structure, then you can use generalization, however Project and Phase would be on the generalized end (the one with arrow) while a specific ProjectType and ProjectPhase would be on the specialized end (without arrow). If you follow this method you are able to show detailed structure of each ProjectType. See the example for details. Note also how some additional constrains are used to more precisely define how to understand the logic of modelled system. Finally be aware that in my diagram I made an assumption that each Project as well as Phase has to be of a specific type. You cannot have a Project as such (which not necessarily has to be true) and thus I made them abstract. Here a Project IS of a certain ProjetType .
The other option is to use the ProjectType and PhaseType as attributes of respectively Project and Phase and keep the logic of which types should be in a specific type of Project elsewhere. In such case you usually model ProjectType and PhaseType as enumerators and then put them as attributes in respectively Project and Phase linking respective elements with Dependency. Here Project HAS certain ProjetType .
Notes
Evidently the assignment of Employee to the Project is done only through the Phase so the direct relationship is redundant. You can eventually depict it as a derived relationship.
This example uses the first approach. Note that I define exact, specific types of Projects, not some undefined general ProjectType (same for Phases).
I completely omit a redundant information about a relationship between Employee and Phase in this example.
This example does not provide details about structure of specific type. You will probably want to add here additional classes that create a template for your Project to define how should Project structure look like (which Phases are included). This classes are not presented on the example diagram. Moreover I've added the direct derived association between Employee and Project.
Some obvious errors:
As I see it, this will fit your explanation:
You don't need an association from Employee
to Project
since it's linked via phase and type. There is no explanation of the phase
so I just added a simple attribute. I'd guess it's an enumeration or a string. Eventually ProjectType
is also a simple enum and could be replaced by an attribute within Project
(would need investigation).
I think this is the class diagram that suits your requirements:
I have modeled composition associations between Project/ProjectPhase and between ProjectType/Phase, because a Project consists of ProjectPhases and ProjectPhases cannot exist without their Projects and the same is true for ProjectType/Phase.
Employees and ProjectPhases neither have a part-of relationship nor an existency dependency, hence a compositions association is not appropriate here.
In my diagram, an Employee is implicitly assigned to Projects via ProjectPhases, but if you want to stress the relationship between Employees and Projects, you may very well draw an association between these classes explicitly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.