🚀 Welcome to MDriven Learn –  MDriven is now on Discord!  Don’t miss the latest Release Notes.
Bootcamp:Chapter 1
This page was created by Stephanie on 2023-04-18. Last edited by Wikiadmin on 2026-07-29.

You can use this first Bootcamp chapter to create a small object model in MDriven Designer, enter test data in the debugger, persist it as XML, and model a one-to-many association between people and cars.

What you will build

You will create two classes:

  • Person, with a Name attribute.
  • Car, with a RegistrationNumber attribute.

You will then connect them so that a person can have zero or more cars they previously owned, while each car has zero or one previous owner.

Model element Name Meaning in this exercise
Class Person A type of object representing a person.
Attribute Person.Name A string value, such as Alex.
Class Car A type of object representing a car.
Attribute Car.RegistrationNumber A string value, such as OldCar1.
Association end CarsIUsedToOwn The cars associated with a person; cardinality 0..*.
Association end PreviousOwner The person associated with a car; cardinality 0..1.

Before you start

  1. Complete the installation instructions in the Before Starting Guide.
  2. Start MDriven Designer.
  3. Create a new empty model.
  4. Save it in a location you can find again. This chapter uses C:\temp\MDrivenEducation\Start.modlr as an example; use an equivalent location if needed.

Save the model regularly with Ctrl+S. The model file stores the class definitions, attributes, and associations that you create. The test objects you create later are saved separately in the XML persistence file.

Create the Person class

  1. Create a class named Person.
  2. Add an attribute named Name to Person.
  3. Set the attribute type to string.
  4. Save the model.

For example, a Person object can later have Name set to Alex.

Run the model with XML persistence

XML persistence stores the objects created during this exercise in an XML file on disk. It is appropriate here because you are learning the model and debugger workflow.

  1. Select the Play button at the left side of the top menu.
  2. Choose XML persistence.
  3. Select Start system.
  4. Select Show debugger.

Query objects in the debugger

The debugger lets you inspect and create objects while the model is running. In its Expression box, enter the expression used in this Bootcamp exercise:

person.allinstances

Execute the expression. The result list is empty because you have defined the Person class but have not created any Person objects yet.

Create and save Person objects

  1. In the debugger, open a Seeker. A Seeker is the search and result view for objects of a selected class.
  2. Select the Person class. The search result is empty.
  3. Select Create New twice to create two rows.
  4. Select the first row, right-click it, and select Open.
  5. In the AutoForm, enter your name in the Name field.
  6. Open the second row and enter another name, such as SomeOtherDude.
  7. In the debugger, use the save button to save the created objects.

Run the expression again:

person.allinstances

You should now see two rows. This verifies that two Person objects exist in the running system.

Inspect the persisted XML

  1. Find the XML file on disk in the same location as the model file.
  2. Open the XML file in Notepad or another text editor.
  3. Search for one of the names you entered.
  4. Close the text editor without changing the file.

This confirms that XML persistence saved the test objects outside the model definition.

Verify that objects survive a restart

  1. Close the debugger.
  2. Close the Play dialog, also called the system prototyper.
  3. Close MDriven Designer and save if prompted.
  4. Start MDriven Designer again.
  5. Open the model from Recent files.
  6. Select Play, choose XML persistence, start the system, and open the debugger.
  7. Execute person.allinstances again.

Verify that the two Person objects are still present. If the result is empty, check that you reopened the same model and started it with XML persistence.

Find model elements in the model tree

The model tree at the right side of MDriven Designer lets you find elements throughout the model.

  1. Close the debugger and the Play dialog.
  2. Type Person in the search box above the model tree.
  3. Observe the results. You should find both the Person class and its Name property.
  4. Select Person in the tree.
  5. In the property inspector below the tree, change its default color to cyan, or choose another color you can recognize easily.
  6. Press Escape in the search box, or clear it, to return to the complete model tree.

Use this search whenever you need to return to a class, attribute, diagram, or other model element.

Work with Diagram1

A diagram is the visual workspace where you arrange and connect model classes.

  1. Find Diagram1 in the model tree.
  2. Double-click Diagram1 to open it.
  3. If the diagram is empty, drag Person from the model tree onto the diagram.
  4. If the Start wizard is not visible, select Start! at the upper-left corner.
  5. Right-click the diagram and select Add class.
  6. Rename the new class to Car.
  7. Use the zoom buttons or Ctrl+mouse wheel to adjust the diagram view.
  8. Add an attribute named RegistrationNumber to Car and set its type to string.
  9. Save the model.

Create the Person-to-Car association

An association defines how objects of two classes relate. In this example, it records historic ownership.

  1. Enter AssociationMode by selecting the association arrow in the toolbar.
  2. Click, drag, and hold from Person.
  3. Move the pointer to Car and release it to create the association.
  4. Select the association end at Person's side and name it CarsIUsedToOwn.
  5. Set CarsIUsedToOwn cardinality to 0..*.
  6. Select the association end at Car's side and name it PreviousOwner.
  7. Set PreviousOwner cardinality to 0..1.
  8. Save the model.

The cardinalities mean:

  • A Person may be associated with no cars or with many cars through CarsIUsedToOwn.
  • A Car may have no recorded previous owner or one recorded previous owner through PreviousOwner.

Explore the auto diagram

  1. Search for Car in the model tree.
  2. Double-click Car.

This opens an auto diagram rather than Diagram1. The auto diagram centers the selected class and shows connected classes, including Person.

  1. Select Person in the auto diagram.
  2. Observe that the auto diagram recenters on Person and keeps Car as a connected class.
  3. Use the model-tree search to find and reopen Diagram1 when you want to return to your manually arranged diagram.

Create cars for a person

  1. Select Play.
  2. Choose XML persistence and open the debugger.
  3. Execute person.allinstances.
  4. Select the person object that contains your name.
  5. Find and select the multi-link button for CarsIUsedToOwn.
  6. Select Add New three times to create three related cars.
  7. Open each car AutoForm and set RegistrationNumber to the following values:
Car RegistrationNumber
First car OldCar1
Second car OldCar2
Third car OldCar3
  1. Save the debugger data.

You have now created one person with three associated historic cars. The association is visible through the CarsIUsedToOwn multi-link on the selected person.

Checkpoint

Before continuing, verify all of the following:

  • The model contains Person and Car.
  • Person has the string attribute Name.
  • Car has the string attribute RegistrationNumber.
  • The association has the ends CarsIUsedToOwn (0..*) and PreviousOwner (0..1).
  • XML persistence contains two saved Person objects.
  • One person has three cars with registration numbers OldCar1, OldCar2, and OldCar3.

Next chapter

Continue with Training:Bootcamp:Chapter 2.

See also

Prerequisites

Prerequisites

Before starting the exercises, complete the installation instructions in the Before Starting Guide.

You will use MDriven Designer to create and save a model. In this chapter, you will also start the system with XML persistence and inspect the XML file created for the test objects.

When you create the new model, save it in a location you can find again. The chapter uses C:\temp\MDrivenEducation\Start.modlr as an example; an equivalent location is also acceptable.

Continue with Step 1 after completing the installation guidance.