How to Create a UML Object Diagram

In this tutorial, we will guide you through the process of creating a UML Object Diagram in Software Ideas Modeler. We will use an existing project that includes a class diagram called ThemeSystem, which contains three primary classes: AppTheme, Color, and Font. This object diagram will represent different app themes, demonstrating how you can visualize object instances and their relationships in real-time.

Step 1: Understanding the Class Diagram

Before creating the object diagram, let’s review the existing ThemeSystem class diagram. You can download the project here. This diagram includes the following classes:

  • AppTheme: Defines the application’s theme with attributes like ButtonColor, BackgroundColor, BorderColor, TitleFont, and DefaultFont.
  • Color: Stores color values using RGB attributes (R, G, B) and allows the color to be named.
  • Font: Specifies the font name, size, and style attributes like Bold, Italic, and Underline.

Step 2: Creating a New UML Object Diagram

Create a New Object Diagram - Click the Plus button in the tab bar and select Object Diagram from the drop-down menu. This will create a new, empty UML Object Diagram.

Object Diagrams are great for showing real-time object instances, such as different configurations of app themes in our case.

Step 3: Defining Color Objects

Now, let’s define specific color objects for the application themes.

Add Color Object to the Diagram

In the Project sidebar, locate the ThemeSystem class diagram. Expand its node and drag the Color class onto the object diagram canvas. This will create an instance specification with Color set as the classifier reference.

Rename the Object

Rename this object instance to WhiteSmoke by double-clicking the object name. The name appears before the colon, and the class name (Color) remains after the colon.

Add Attributes to the Object

To add attributes from the class definition, click the Add Attributes button in the context bar. In the dialog box that appears, select All Attributes and confirm by clicking OK.

Set Attribute Values

Now, fill in the attribute values for the WhiteSmoke object:

  • Name: WhiteSmoke
  • R: 245
  • G: 245
  • B: 245

Create a Second Color Object

Follow the same steps to create another color object called LightBlack:

  • Name: LightBlack
  • R: 50
  • G: 50
  • B: 50

Step 4: Defining Font Objects

Next, we’ll define fonts for our app themes.

Add a Font Object

Drag the Font class from the ThemeSystem class diagram into the object diagram. Rename this object instance to Arial.

Add Attributes

Add all attributes from the Font class, following the same steps as before.

Set Attribute Values

Set the values for the Arial object:

  • Name: Arial
  • Size: 12
  • Bold: False
  • Italic: False
  • Underline: False

Create a Bold Font Object

You can easily copy the Arial object to create a new font object. Right-click and drag the Arial object while holding the right mouse button, then select Copy Here (Independent) from the context menu. Rename this copy to ArialBold and set the Bold attribute to True.

Step 5: Creating AppTheme Objects

Now, we’ll define app themes using the AppTheme class.

Add AppTheme Objects

Drag the AppTheme class from the ThemeSystem class diagram into the object diagram. Rename the first instance to LightTheme and the second to DarkTheme.

Add Attributes

Add all attributes to both theme objects and set the Name attribute to match the object’s name (LightTheme and DarkTheme).

Step 6: Setting Attribute Values for Themes

Let’s now associate the color and font objects with the AppTheme objects.

Set Colors for LightTheme

  • Right-click and drag the WhiteSmoke color object to the ButtonColor attribute of the LightTheme object. Choose SetValue from the context menu.
  • Repeat this process to assign WhiteSmoke to the BackgroundColor attribute.
  • Right-click and drag the LightBlack color to the BorderColor attribute, and select SetValue.

Set Fonts for LightTheme

  • Right-click and drag the ArialBold object to the TitleFont attribute, and select SetValue.
  • Drag the Arial object to the DefaultFont attribute, and select SetValue.

Define DarkTheme in the Same Way

Follow the same process to set the color and font attributes for the DarkTheme object. You can use different instances of color and font objects if needed.

Step 7: Adding Associations

To complete the object diagram, we’ll add associations between the AppTheme objects and their related color and font objects.

Use the Selection Tool to select all the color and font objects in the diagram.

Use the Association Tool

In the toolbox, drag the Association tool button and drop it over the LightTheme object and then again over the DarkTheme object to create the relationships between the themes and their corresponding colors and fonts (the selected objects).

Complete UML Object Diagram Example

UML Object Diagram example
UML Object Diagram example

Download Example

You can download the project file with the example object diagram here:

App Themes (UML Object Diagram, UML Class Diagram)

New Comment

Comment