You can model and run a small team task planner in MDriven Designer to learn how classes, associations, OCL, validation, and generated ViewModels work together.
This tutorial is for new MDriven users who want a concrete first model rather than a theoretical introduction. You will create a planner with teams, projects, members, and tasks, then generate forms to test it in a browser.
What you will build
The planner records these business concepts:
| Concept | Purpose | Example |
|---|---|---|
| Team | Groups projects and members. | Operations |
| Project | Holds work that the team plans to complete. | Warehouse move, with a deadline of 2026-09-30 |
| Task | Represents one item of work and its completion status. | Confirm delivery date, priority 2, completed or not completed |
| Member | Represents a person who can be assigned a task. | Alex, alex@example.com |
When you complete a task, the project's completed-task count and progress are calculated from the model. You do not enter those values manually.
Before you start
Open MDriven Designer and create or open a model. This walkthrough uses MDriven's generated forms as a starting point; refine the generated ViewModels when the default screens no longer match the task-planning workflow you need. For an introduction to designing a ViewModel around a specific user task, see Training:The declarative ViewModel.
Create the domain model
A domain model describes the things your application handles and how they relate. Add these four classes to the diagram:
TeamProjectTaskMember
Add associations
Create the following associations. Name the association ends as shown so that the OCL examples later in this tutorial have the required navigation paths.
| From class | Association end | To class | Multiplicity and meaning |
|---|---|---|---|
| Team | projects
|
Project | One team can have many projects; each project belongs to one team. |
| Project | tasks
|
Task | One project can have many tasks; each task belongs to one project. |
| Task | member
|
Member | A task can be assigned to a member. |
For example, a project named Warehouse move can have the tasks Book transport and Confirm delivery date. Assigning the second task to Alex sets that task's member association.
Add attributes
Add the following stored attributes to the indicated classes.
| Class | Attribute | Type | Example value |
|---|---|---|---|
| Project | Name
|
String | Warehouse move |
| Project | Deadline
|
Date | 2026-09-30 |
| Task | Title
|
String | Confirm delivery date |
| Task | IsCompleted
|
Boolean | false |
| Task | Priority
|
Integer | 2 |
| Member | Name
|
String | Alex |
| Member | Email
|
String | alex@example.com |
Use the same spelling and capitalization in the following expressions. OCL expressions navigate the model by attribute and association-end name.
Calculate project status with OCL
OCL (Object Constraint Language) is the expression language used to query and calculate from the model. Add the following derived attributes to Project.
Count all tasks
Create a derived attribute named TotalTasks. Its expression counts the tasks reached through the project's tasks association.
self.tasks->sizeFor a project with three tasks, TotalTasks is 3.
Count completed tasks
Create a derived attribute named CompletedTasks. Its expression selects completed tasks and counts the result.
self.tasks->select(IsCompleted)->sizeIf one of the three tasks is completed, CompletedTasks is 1.
Calculate progress
Create a derived attribute named Progress with type Double. Use this expression:
if self.TotalTasks = 0
then 0
else
(self.CompletedTasks * 100) / self.TotalTasks
endifThe zero-task condition prevents a division by zero. With three tasks and one completed task, the expression calculates the project's percentage from those two counts. Because Progress is derived, users should change IsCompleted on tasks rather than editing progress directly.
For more examples of expressions and their collection operations, see Documentation:MDriven Turnkey Series.
Add a priority validation rule
A validation rule states a condition that data must meet. Add a validation to the Task.Priority attribute that accepts priorities from 1 through 5:
(self.Priority >= 1) and (self.Priority <= 5)Set a clear user message, for example: Priority must be between 1 and 5.
Test the rule with these values:
| Entered priority | Expected result |
|---|---|
| 1 | Accepted |
| 3 | Accepted |
| 5 | Accepted |
| 0 | Rejected with the validation message |
| 6 | Rejected with the validation message |
Keep the rule on the model attribute so that the rule remains part of the domain definition as you develop the application.
Generate starter forms
Use AutoForms to create a starting set of views from the classes, attributes, and associations you modeled.
- Right-click an empty area of the diagram canvas.
- Point to AutoForms.
- Select Create/Refresh AutoForms.
- Review the generated ViewModels and views.
AutoForms provides a working starting point for editing and listing the modeled objects. It does not replace workflow-specific design: refine the generated ViewModels when users need a focused screen, such as a project overview that shows its task list and progress. Training:The declarative ViewModel explains this declarative approach.
Run and test the planner
Run the model using the MDriven prototyping option or MDriven Turnkey. Turnkey is the web-application path described in Documentation:MDriven Turnkey Series.
Create test data in this order:
- Create a team.
- Create a member, such as Alex.
- Create a project and give it a name and deadline.
- Create several tasks for that project.
- Assign a task to Alex.
- Set different values for
Priority, including an invalid value such as 6 to verify the validation. - Mark one task as completed.
- Check that
TotalTasks,CompletedTasks, andProgressreflect the task data.
For example, create three tasks for Warehouse move and complete one. The project should show three total tasks, one completed task, and progress calculated from those values. Then complete a second task and verify that the derived values change without manually updating the project.
Where to take the model next
This model is intentionally small. Extend it from a real user need rather than adding fields without a use case. Examples include a focused project-status ViewModel, task filtering, or a workflow that controls when a task can be completed. MDriven development is iterative: model the information and rules, try the application with data, refine the views for the user task, and repeat.
