1.1.9 How to Map Objects From UML Object Diagrams to C#

Video: Instantiate Objects per Object Diagrams (3:43)
A UML Object and a C# Object Can Represent the Same Instance

A UML object diagram shows a snapshot.

C# creates and works with objects while the program runs.

Suppose the UML contains:

Object diagram showing UML object identity type, then C# new expression, then runtime object.
UMLObjectIdentityType.
  • New
  • Changed
  • Removed

The debugger does not replace the UML.

It provides evidence about what the C# program actually created.

The Core Translation

For a basic object header:

objectIdentity : Type

a basic C# creation pattern is:

Type objectIdentity = new Type();

Use the actual names and types supplied by the current UML and project.

The next Learning Activity maps the field values inside those object boxes to the corresponding C# object state.