Drawing class diagrams

A class diagram shows the objects that are required and the relationships between them. Since it provides detailed information about the properties and interfaces of the classes, it can be considered as the main model and regard the other diagrams as supplementary models.

Creating class diagram

Right click Class Diagram on Diagram Navigator and select New Class Diagram from the pop-up menu to create a class diagram.

Create class diagram
Create class diagram

Creating class

To create class, click Class on the diagram toolbar and then click on the diagram.

Create class
Create class

A class will be created.

Class created
Class created

Creating association

To create association from class, click the Association -> Class resource beside it and drag.

Create association
Create association

Drag to empty space of the diagram to create a new class, or drag to an existing class to connect to it. Release the mouse button to create the association.

Association created
Association created

To create aggregation, use the Aggregation -> Class resource instead.

Create aggregation
Create aggregation

To edit multiplicity of an association end, right-click near the association end, select Multiplicity from the popup menu and then select a multiplicity.

Edit multiplicity
Edit multiplicity

To show the direction of an association, right click on it and select Presentation Options > Show Direction from the pop-up menu.


Show direction

The direction arrow is shown beside the association.

Direction shown
Direction shown

Creating generalization

To create generalization from class, click the Generalization -> Class resource beside it and drag.

Create generalization
Create generalization

Drag to empty space of the diagram to create a new class, or drag to an existing class to connect to it. Release the mouse button to create the generalization.

Generalization created
Generalization created

Creating attribute

To create attribute, right click the class and select Add > Attribute from the pop-up menu.

Create attribute
Create attribute

An attribute is created.

Attribute created
Attribute created

Creating attribute with enter key

After creating an attribute, press the Enter key, another attribute will be created. This method lets you create multiple attributes quickly and easily.

Create attribute with Enter key
Create attribute with Enter key

Creating operation

To create operation, right click the class and select Add > Operation from the pop-up menu.

Create operation
Create operation

An operation is created.

Operation created
Operation created

Similar to creating attribute, you can press the Enter key to create multiple operations continuously.

Drag-and-Drop reordering, copying and moving of class members

To reorder a class member, select it and drag within the compartment, you will see a thick black line appears indicating where the class member will be placed.

Reorder class member
Reorder class member

Release the mouse button, the class member will be reordered.

Class member reordered
Class member reordered

To copy a class member, select it and drag to the target class while keep pressing the Ctrl key, you will see a thick black line appears indicating where the class member will be placed. A plus sign is shown beside the mouse cursor indicating this is a copy action.

Copy class member
Copy class member

Release the mouse button, the class member will be copied.

Class member copied
Class member copied

To move a class member, select it and drag to the target class, you will see a thick black line appears indicating where the class member will be placed. Unlike copy, do not press the Ctrl key when drag, the mouse cursor without the plus sign indicates this is a move action.

Move class member
Move class member

Release the mouse button, the class member will be moved.

Class member moved
Class member moved

Model name completion for class

The model name completion feature enables quick creation of multiple views for the same class model. When create or rename class, the list of classes is shown.

Model name completion
Model name completion

Type text to filter classes in the list.

List filtered by typed text
List filtered by typed text

Press up or down key to select class in the list, press Enter to confirm. Upon selecting an existing class, all class members and relationships are shown immediately.

Multiple views of the same model
Multiple views of the same model

Continue to complete the diagram.

Completed diagram
Completed diagram

Generalization set

A generalization set defines a particular set of generalization relationships that describe the way
in which a general classifier (or superclass) may be divided using specific subtypes. To define a generalization set, select the generalizations to include, right click and select Generalization set > Create Generalization Set... from the popup menu.

Create a generalization set
Create a generalization set

Name the set in the Manage Generalization Sets dialog box, and confirm by pressing OK.

Name the generalization set
Name the generalization set

The selected generalizations are grouped. Adjust the connector to make the diagram tidy.

Adjust connector
Adjust connector

Repeat the steps for other generalizations.

Generalization sets defined
Generalization sets defined

Defining delegate method for class

When project's programming language is set to be Visual Basic or C#, it is possible to define delegate method for classes. To define delete method, right click on the class and select Stereotypes > Delegate from the pop-up menu.

Stereotype class as Delegate
Stereotype class as Delegate

Hiding (and showing) attributes and operations

Per workspace

This applies to new classes that will be created in a project opened in specific workspace. To change the setting:

  1. Select Tools > Options from the main menu to open the Options dialog box.
  2. Click Diagramming on the list.
  3. Open the Class tab.
  4. Click Presentation tab.
  5. Change the settings for Show attribute option and/or Show operation option.
    Show or hide operations
    Show or hide operations

Per diagram

This applies to classes in specific diagram. To change the setting:

  1. Right click on the class diagram to set the option.
  2. Select Presentation Options > Attribute Display Options / Operation Display Options from the pop-up menu.
  3. Select Hide All / Show All / Show Public Only.
    Change the operations' presentation options for classes in diagram
    Change the operations' presentation options for classes in diagram

Per class

This applies to specific class. To change the setting:

  1. Right click on the class to set the option.
  2. Select Presentation Options > Attributes / Operations from the popup menu.
  3. Select Hide All / Show All / Show Public Only.
    Change the operations' presentation options for a class
    Change the operations' presentation options for a class

For specific attribute/operation

Instead of showing or hiding all members or public members, you may show/hide specific class member per class. To do this:

  1. Right click on the class to set the option.
  2. Select Presentation Options > Attributes / Operations > Customized... from the pop-up menu.
    Show or hide specific class member
    Show or hide specific class member
  3. Select Customized under the drop down menu of Show.
    Select Customized in dialog box
    Select Customized in dialog box
  4. Select the member(s) to hide and click > to hide them.
    Select attributes to hide
    Select attributes to hide
  5. Click OK button to confirm.

Setting initial (default) value for attribute

Initial value can be set to an attribute, indicating the default value of the attribute when the owning object is instantiated. You can give a text value for initial value, or select an attribute of another class. To set initial value to an attribute:

  1. Open the specification dialog box of attribute by right clicking on the attribute and selecting Open Specification... from the popup menu.
    Opening the attribute specification
    Opening the attribute specification
  2. In the General page of the specification dialog box, enter the initial value in initial value field if it is a text value, or popup the drop down menu to select a public and static field of any class to be the value.
    Selecting an initial value
    Selecting an initial value
    NOTE: In order to select the attribute of another class to be the default value, make sure the attribute you want to select is static (i.e. set to be in classifier scope) and is public (so that other classes can access).
  3. Click OK to confirm.

 

 

 
Chapter 4. Structure Modeling Table of Contents 2. Drawing object diagrams
 

Product

Try this feature with

Visual Paradigm for UML

Technical Support

Have technical issues or suggestions? Please contact Visual Paradigm Support Team.

Sales Support

Have questions related to registration, licensing or payment? Feel free to contact Visual Paradigm Sales Team.

Discussion Forum

Share your suggestions of opinions at VP Discussion Forum.