Create a Class Diagram

To create a new UML Class Diagram:

  1. Open the Diagram menu.
  2. Select Class Diagram.
    Screenshot: Create Class Diagram menu

A new Class Diagram canvas will appear in the editor.


Auto-create Class Diagrams

Astah can automatically generate Class Diagrams from Packages. This is useful when you want a quick visualization of an existing model or imported source code.

Before You Begin

If you are working with source code, import it first:

If you are using Astah Professional or Astah UML version 11 or later, you can also use AI Code Reverse to automatically generate Class diagrams from source code. For details, see the AI Code Reverse page.

Generate a Diagram Automatically

  1. Right-click a Package in the Tree view.
  2. Select Auto Create Class Diagram.
    Screenshot: Auto Create Class Diagram menu

You can choose from three presentation options.

1. Simple

Generates a diagram containing Classes only. Attributes and operations are not displayed.
Auto Create Class Diagram in Simple Way

2. Detailed

Generates a diagram including classes, attributes, and operations.
Auto Create UML Class Diagram

3. Unpack Subpackages

Generates a diagram including all models inside the selected package and its subpackages.
Unpack SubPackages


Class

Create a Class

There are five different ways to create a Class in the Diagram Editor. For a full list, refer to the Diagram Editor documentation.
UML Class

Controlling Displayed Information in Classes

You can customize the appearance of Classes – such as choosing which details to display – via the [Extended Visibility] menu.
Class Visibility


Template Classes

A Template Class allows you to define template parameters (generics).
Template Class

Create a Template Class

You can add template parameters in two ways:

  1. Right-click the class and select Add Template Parameter.
    Screenshot: Add Template Parameter


  2. Enter details in the Template Class tab in the bottom-left Property view.
    Screenshot: Template Class properties

Attributes

Attributes represent the data fields of a Class.
UML Class Attribute

Add an Attribute

You can create attributes using:

1. Draw Suggest

Hover over a Class and click the orange diamond.
Attribute Diamond

2. Keyboard Shortcut

When an attribute is selected, press Enter to create another.

3. Paste Text

You can paste copied text to create multiple attributes at once.

Attribute Visibility

To show or hide attributes:

  1. Open the Initial Visibility tab in the bottom-left Property view.
  2. Select the visibility options.
  3. Click Apply to existing elements.
    Initial Visibility in Class Diagram

Operations

You can create Operations by hovering over a Class and clicking the green bar that appears.
Green bar to add operations

Another way is to press the [Enter] key while an operation is selected.

Moving Attributes/Operations

Attributes and operations can be moved by dragging them within a class or to another class.

Since version 8.5, you can add Operations by pasting copied text.


Anonymous Bound Class

You can create an anonymous bound class by deleting the name of a Bound Class.
Anonymous Bound Class

Anonymous Bound Classes can be used for the following:

  • Attribute Type
  • Operation Return Value
  • Operation Parameter Type
  • The target of Association End A and Association End B
  • Base Class of Instance Specification in Class
  • Base Class of Object Node in Activity Diagram
  • Base Class of Lifeline in Sequence Diagram and Communication Diagram

Example of creating a Bound Class

  1. Create a bound class.
  2. Create a new class and add an attribute whose type is the bound class.
    Bound Class

  3. When you add the class, you will be asked if you’d like to create a new class. Click [Yes].
    Dialog asking whether to create a new class

  4. Right-click and select [Show Hidden Relationship] from its pop-up menu.
    Show hidden menu

  5. The relationship to the anonymous bound class is now shown.
    Anonymous Bound Class

Nest a Class

You can nest a class within a package by dragging it into the package.


Enumerations

  1. Choose [Enumeration] from the Class drop-down menu on the tool palette.
    Enumeration
  2. Click in the diagram editor to place it.
    Enumeration created

Enumeration Literals

There are three ways to create Enumeration Literals:

  1. Using Draw Suggest: Hover over an Enumeration and click the purple mini bar to add a new enumeration literal.
    Adding Enumeration Literals by Draw Suggest
  2. Using the context menu: Right-click an Enumeration and select [Add Enumeration Literal].
    Adding an Enumeration Literal from the context menu
  3. From the Property view: Select an Enumeration, then in the Property view (bottom-left pane), click the [Enumeration Literal] tab and click [+].
    Adding Enumeration Literal from Property View

Association

To create associations, hover over a Class, select the appropriate association type from the icons, and click the target models. For more details, see the “Drawing Lines” section.

Jump to Association Ends

You can navigate to the Association ends by right-clicking the association line and selecting [Move to related element].
Move to Related Element

Relocating Association Names

If association names drift from the line, right-click the line and select [Init Label Position] to reset the label’s position.

Bring association name back

Association Class

Create an Association Class

  1. Click the Association Class tool in the palette.
    UML Association Class
  2. Click the two Classes that the Association Class should connect.

Astah will place the Association Class between them.
Association Class on the UML Class Diagram