Create the domain model
A domain model is the class diagram that describes the important concepts in the application and the relationships between them. For this planner, the concepts are Team, Project, Task, and Member.
Before you start, create a new empty model and save it. Save regularly with Ctrl+S. For an introduction to the Designer workspace, see Documentation:MDriven designer overview Part 1.
Open a class diagram
- In the repository tree, find
Diagram1and double-click it to open the diagram canvas. - If the diagram is empty, keep it open. You will add the planner classes to this canvas.
- If you need a new diagram, create an Add Class diagram from the overview screen. The diagram is also shown in the repository tree.
Add the four classes
- Right-click an empty area of the diagram canvas.
- Select Add class.
- Rename the new class to
Team. - Repeat the previous two steps to create
Project,Task, andMember. - Arrange the classes so that Team is near Project, Project is near Task, and Task is near Member. For example, place them in that order from left to right so that each planned relationship is easy to see.
- Press
Ctrl+S.
You can also find any class in the repository tree by using the search box. Double-clicking a class in the tree opens its auto diagram, which shows that class and its related classes.
Draw the associations
An association is a relationship between two classes. For example, the Team-to-Project association represents that a team has projects.
- Select association mode by pressing the association-arrow button in the diagram toolbar.
- Click, drag, and hold from
TeamtoProject; release the mouse overProject. - Create a second association from
ProjecttoTask. - Create a third association from
TasktoMember. - Select each association end and use the property inspector to set its name and multiplicity. Multiplicity (also called cardinality) states how many objects can occur at that end of the relationship.
- Configure the associations to express these planner rules:
| Association | Rule to model |
|---|---|
| Team to Project | A Team has many Projects. |
| Project to Task | A Project has many Tasks. |
| Task to Member | A Task can be assigned to a Member. |
Press Ctrl+S after configuring the associations.
Check the model before continuing
Your diagram should now show four classes and three association lines:
Teamconnected toProjectProjectconnected toTaskTaskconnected toMember
Do not use Delete to remove a relationship that you intend to remove from the model: it removes the relationship only from the diagram. Use Ctrl+Delete to delete it from both the diagram and the model. If you removed an association from the diagram by mistake, right-click the class, select Introduce&Remove, and select Re-introduce removed associations.
Continue with the attributes for Project, Task, and Member, then add the derived Project attributes with OCL.
