Skip to main content

Class Diagram

Overview

Class diagrams can be used to visualize the static structure of the system. This page describes the operations for using the class diagram in the following order.

  • Place a class diagram
  • Define a class
  • Define associations

It also provides the following features to assist in user modeling: These will also be explained in order.

  • Validate the model
  • Set the display contents

Class Diagram

Place a class diagram

To place the class diagram, follow the steps below.

Place class diagram

Operation procedure
  1. Select the package in the model navigator and click Add Model> Class Diagram in the context menu.
  2. The class diagram is placed on the child elements of the selected package.

Define a class

Add a class

To add a class, do the following:

Define class

Operation procedure
  1. Drag and drop [Class] from the toolbox onto the displayed class diagram.
  2. A new class is added as a sibling element of the displayed class diagram.
Elements that can be added from the toolbox

In the class diagram, you can place the following elements displayed in the toolbox.

IconName
PackagePackage
ClassClass
InterfaceInterface
NoteNote
LabelLabels
ShapeShape
Add stereotypes to classes

To add a stereotype, do the following:

Add stereotype

Operation procedure
  1. Select a class.
  2. Click the Add button in the Basic information> Stereotype field in the Property inspector to see the choices.
  3. Select a stereotype and press the [OK] button to set the stereotype for the class and display the stereotype at the top of the class shape.
tip

Stereotype choices can be defined in the Detail view of the package model.

tip

You can edit the added stereotype from the class diagram by following the steps below.

  1. Double-click the stereotype displayed in the class to enter the edit state.
  2. If you change the stereotype and confirm the edit, it will be reflected on the class diagram and the stereotype of the class will be changed.
Change class to abstract class

To change a class to an abstract class, do the following:

Change class to abstract class

Operation procedure
  1. Select a class.
  2. Check the checkbox in the Characteristics> Abstract Type field in the Property inspector to make it an abstract class and display the class name in italics.
About font settings

If you want to display the Japanese class name in italics, change the font from [Shape]> [Text]> [Font Setting] on the ribbon to the font that supports italics.

tip

If you want to display an existing class on the class diagram, you can display it by dragging and dropping the class on the model navigator to the class diagram.

Add an attribute

To add an attribute to the class diagram, do the following:

Add attribute

Operation procedure
  1. Click the [+] button in the attribute pane of the displayed class shape.
  2. The attribute is added to the partition and it is in the edit state.
  3. Enter and confirm the attribute you want to add according to the text notation below, and the attribute will be added.
About text notation of attributes

When you enter text for an attribute on the class diagram, it is parsed according to the notation format of the attribute and reflected in each field value of the attribute. Of course, if you change each field value, it will be reflected in the text on the figure.

Edit Attributes

Correspondence between the text notation format of the attribute and each field value
The attributes are displayed and parsed as text according to the following format.

  • format
    <Attribute> :: = [<Visibility>] [<Derived attribute?>] <Attribute name> [':' <Type name>] ['[' <Multiplicity lower limit>' ..' <Multiplicity upper limit>']'] ['=' <initial value>]
    • supplement
      • <Visibility> displays one of the following:
        • '+' (Public),'-' (Private),'#' (Protected),'~' (Package/Internal)
      • If <derived attribute or> is true, '/' is displayed.
      • If <type name> contains * or &, the character string before the corresponding character is treated as the type name, and the character string after the corresponding character is treated as the type qualifier. To set a type name starting with * or &, use the Inspector.
    • example
      Attribute name: TargetValue, Visibility: Public, Derived attribute: true, Type: int, Type qualifier: *, Multiplicity lower limit: 0, Multiplicity upper limit: 2, initial value: -1, the following text will be displayed.
      +/TargetValue: int*[0..2]=-1

Add an operation

To add an operation to the class diagram, do the following:

Add operation

Operation procedure
  1. Click the [+] button in the control area of the displayed class shape.
  2. The operation is added to the partition and it is in the edit state.
  3. Enter and confirm the operation you want to add according to the text notation below, and the operation will be added.
Text notation of operation

When you enter text on an operation on a class diagram, it is parsed according to the notation format of the operation and reflected in each field value of the operation. Of course, if you change each field value, it will be reflected in the text on the figure.

Edit Operation

Correspondence between the text notation format of the operation and each field value
The operation is displayed and analyzed as text according to the following format.

  • format
    <Operation> :: = [<Visibility>] <Operation name> ['(' [<Parameter list>]')'] [':' [<Return type>] ['[' < Multiplicity>']']
    • supplement
      • <Visibility> displays one of the following:
        • '+' (Public),'-' (Private),'#' (Protected),'~' (Package/Internal)
      • <List of parameters> is displayed in the following format.
        • <List of parameters> :: = <Parameters> [',' <Parameters>] *
        • <Parameter> :: = [<Parameter direction>] <Parameter name>':' <Parameter type name> ['[' <Parameter multiplicity>']'] ['=' <Parameter Initial value>]
          • If <parameter type name> contains * or &, the character string before the corresponding character is treated as the type name, and the character string after the corresponding character is treated as the type qualifier. .. To set a type name starting with * or &, use the Inspector.
          • <Parameter direction> displays one of the following:
            • in, out, inout
    • example
      Operation name: Drive, Visibility: Public
      Parameter 1 name: miles, type: int, type qualifier: &, initial value: 100, multiplicity:1.. *
      Parameter 2 name: speed, type: int, direction: out
      In the case of, the following text will be displayed.
      + Drive (miles: int&[1..*]=100, out speed: int)

Define associations

To define the association, do the following:

Define associations

Operation procedure
  1. Move the pointer over the class you want to associate.
  2. Drag the [โ–ฒ] icons that appear on all sides of the class and drop them on the other class you want to associate with.
  3. A list of associations that can be added will be displayed. Select the association you want to add, and the selected association will be added.
Related that can be added

The following associations are available in the class diagram:

IconName
RequiresDependencies
RelationshipRelated
Related (unidirectional)Related (unidirectional)
EmbeddedOwned
AggregateAggregate
GeneralizationInheritance
RealizationRealization
Edit related multiplicity

Edit related multiplicity

Operation procedure
  1. Select a relationship.
  2. Double-click the grayed out [*] to enter the editing state.
  3. Enter the multiplicity you want to set, the multiplicity will be set for the association, and the multiplicity will be displayed for the association in the class diagram.
Edit related end names

Edit related end names

Operation procedure
  1. Select a relationship.
  2. Double-click the grayed out [-] to enter the editing state.
  3. When you enter the related end name you want to set, the related end name is set for the association and the related end name is displayed for the association in the class diagram.
Add stereotypes to associations

To add a stereotype, do the following:

Add stereotype

Operation procedure
  1. Select a relationship.
  2. Double-click the grayed out [<< stereotype>>] to enter the edit state.
  3. When you enter the stereotype you want to set, the stereotype is displayed in the association of the class diagram, and the stereotype is set in the association.

Validate the model

The contents verified in the class diagram are as follows.

  • Is the inheritance relationship of classes and interfaces circular?
  • Is the class set in the inheritance source of the interface?
  • Is there a subclass set for the final class?

To validate your model, do the following:

Circular Inheritance

Operation procedure
  1. From the ribbon, run UML> Verification> Check Consistency.
  2. If the status is inconsistent for all models under the project, an error will be displayed.
tip

Click the Home> Model> Check Error button on the ribbon to perform validation on all models in addition to standard validation. Also, when a new inheritance relationship is added on the class diagram, the relationship check between the classes is performed in real time based on the added inheritance relationship.

Set the display contents

You can display only the information you are interested in in the class diagram without changing the model. To set the display contents of the operation parameters, follow the procedure below.

Diagram Setting Properties

Operation procedure
  1. Display the class diagram for which you want to switch the display.
  2. Toggle the check boxes in the Operation group of the UML Diagram tab of the Inspector.
Elements that can switch the display

You can switch the display of the following elements in the class diagram.

CategoryElements
CommonStereotype
AttributesVisibility
Type
Multiplicity
Initial value
OperationVisibility
Return type
Parameters
Parameter type
Parameter direction
Initial values of parameters
RelationshipVisibility

Restrictions

  • Italics cannot be specified in the type name style. If the type is an abstract type, it is automatically displayed in italics.
  • If the font of the type name does not support italics, it cannot be represented on the diagram whether it is an abstract type. Check with the sub-editor or inspector.
    • Examples of unsupported fonts: Meiryo (default font)
  • You cannot specify an underline in the attribute style. If the attribute is a static attribute, it will be automatically underlined.
  • Italics cannot be specified in the operation style. If the operation is an abstract operation, it is automatically displayed in italics.
  • You cannot specify an underline in the operation style. If the operation is a static operation, it will be automatically underlined.
  • If you want to specify the type specified by the attribute or operation by text editing, it must be predefined. It does not add automatically.
  • If the name of the type handled by the attribute or operation contains the following characters used in the syntax of the attribute or operation, it may be reflected in the model by misinterpretation when editing the text.
    • "," (Half-width comma), ")" (half-width round bracket closed), "]" (half-width square parenthesis closed), "=" (half-width equal), "*" (half-width asterisk), "&" (half-width) Ampersand)
  • Interface lollipop display is not possible.
  • To change the type of association (dependency, ownership, aggregation, etc.) between classes once added, you need to recreate it.
  • You cannot anchor notes to class attributes, operation elements, or connectors.
  • The ownership relationship between a package and a class cannot be represented by a connector.
  • The following restrictions remain, but the check function can detect problems.
    • You can specify a class as the inheritance source of the interface.
    • You can define circular inheritance.
    • You can define a subclass even if it is a final class.
  • Related classes cannot be defined.
  • Inner classes cannot be represented.