Class Diagrams

Class diagrams are the most common type of UML diagram, used to model the static structure of a system by showing classes, their attributes, operations, and relationships.

Creating Classes

Using the Class Tool

Press A or C to activate the Class tool, then click anywhere on the canvas to place a new class box.

Empty Canvas with Class Tool

Class Box Structure

A UML class box consists of three compartments:

  1. Name compartment - Contains the class name and optional stereotype
  2. Attributes compartment - Lists the class properties/fields
  3. Operations compartment - Lists the class methods/functions

Class Box Structure

Class Properties

Select a class and use the Inspector panel to configure its properties:

Name

The class name appears in bold in the top compartment. Convention uses PascalCase (e.g., CustomerOrder).

Stereotype

Optional classifier that appears above the class name in guillemets:

  • <<interface>> - For interface definitions
  • <<abstract>> - For abstract classes
  • <<enumeration>> - For enum types
  • <<entity>> - For domain entities
  • Custom stereotypes are also supported

Abstract

Toggle to render the class name in italics, indicating an abstract class.

Class Inspector

Attributes

Attributes represent the data/properties of a class.

Adding Attributes

  1. Select the class
  2. In the Inspector, find the Attributes section
  3. Click the + button to add a new attribute
  4. Enter the attribute details

Attribute Syntax

Attributes follow this format: visibility name : type

Visibility Modifiers:

SymbolMeaningDescription
+PublicAccessible from anywhere
-PrivateAccessible only within the class
#ProtectedAccessible within class and subclasses
~PackageAccessible within the same package

Examples:

  • -id: Int - Private integer ID
  • +name: String - Public string name
  • #createdAt: Date - Protected date field
  • ~cache: Map<String, Any> - Package-private cache

Operations

Operations represent the behavior/methods of a class.

Adding Operations

  1. Select the class
  2. In the Inspector, find the Operations section
  3. Click the + button to add a new operation
  4. Enter the operation details

Operation Syntax

Operations follow this format: visibility name(parameters) : returnType

Examples:

  • +getName(): String - Public getter returning String
  • -validate(input: String): Boolean - Private validation method
  • +process(data: Data, options: Options): Result - Method with multiple parameters
  • +save(): void - Method with no return value

Relationships

Press R to activate the Relationship tool, then drag from one class to another to create a connection.

Relationship Types

TypeLine StyleArrowUse Case
AssociationSolid lineOpen arrowGeneral relationship
DependencyDashed lineOpen arrow"Uses" relationship
InheritanceSolid lineHollow triangle"Is-a" relationship (extends)
RealizationDashed lineHollow triangleInterface implementation
AggregationSolid lineHollow diamond"Has-a" (weak ownership)
CompositionSolid lineFilled diamond"Has-a" (strong ownership)

Class Relationships

Creating Relationships

  1. Press R to activate the Relationship tool
  2. Click on the source class
  3. Drag to the target class
  4. Release to create the connection
  5. Use the Inspector to change the relationship type and arrowheads

Relationship Labels

Double-click on a relationship line to add labels:

  • Name - Describes the relationship (e.g., "manages", "contains")
  • Multiplicity - Indicates how many instances (e.g., "1", "0..*", "1..n")
  • Role names - Labels at each end describing the role

Best Practices

  1. Keep it simple - Don't try to model everything; focus on key classes
  2. Use stereotypes - Clearly mark interfaces and abstract classes
  3. Show key relationships - Not every association needs to be shown
  4. Consistent naming - Use PascalCase for classes, camelCase for members
  5. Group related classes - Use visual proximity to show logical groupings