< Previous | Next >

Lesson 4: Creating an object model diagram

In this lesson, you create an object model diagram. Object model diagrams (OMDs) specify the structure and static relationships of the classes in the system. IBM® Rational® Rhapsody® object model diagrams are both class diagrams and object diagrams, as specified in the UML. They show the classes, objects, interfaces, and attributes in the system and the static relationships that exist between them.
To create an object model diagram:
  1. In the Rational Rhapsody model browser, expand the VehicleSensor project.
  2. Right-click the Design package and select Add New > Diagrams > Object Model Diagram.
  3. In the New Diagram dialog box, rename the diagram. The diagram is added in the browser.
  4. To draw the first class, in the drawing toolbar, select the class Class button icon and click in the drawing area.
  5. Place the cursor in the top panel of the class and replace the default name with Button.
  6. Draw two more classes and name them Sensor and Display.
  7. Right-click the Sensor class and select Add New > Attribute.
  8. Rename the attribute Pulse.
  9. Double-click Pulse to display the Attribute dialog box.
  10. Select the General tab and enter the values as shown:
    Attribute window showing the General tab.
  11. Right-click the Sensor class and select Add New > Operation.
  12. Double-click the new operation to display the Operation dialog box.
  13. Select the General tab and rename the operation resetSensor.
  14. Select the Implementation tab and type pulse=0;, then click OK.
  15. Select the display class and add an operation named show(count:int).
  16. Add the following code in the Implementation tab: std::cout << "the pulse count is " << count << std::endl;.
  17. Add an association line from Button to Sensor.
  18. Add another association line from Sensor to Display. Your diagram must resemble this figure:
    Object model diagram showing the Button, Sensor, and Display classes

Lesson checkpoint

In this lesson you learned how to create an object model diagram, including:
  • How to add an object model diagram in Rational Rhapsody
  • Adding functions
  • Adding dependencies
  • Adding implementation code

In the next lesson, you define classes behavior by creating a statechart.

< Previous | Next >

Feedback