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
On a UML Class Diagram page, press U or choose Class from the toolbar's UML menu. Click on the canvas to place a class box, or drag to set its size. Press Return with a class selected to rename it.
Class Box Structure
A UML class box consists of three compartments:
- Name compartment - Contains the class name and optional stereotype
- Attributes compartment - Lists the class properties/fields
- Operations compartment - Lists the class methods/functions
Class Properties
Select a class and use the Inspector's Arrange tab → UML section 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.
Constrained resize
When on (the default), resizing keeps the class box's proportions.
Attributes
Attributes represent the data/properties of a class.
Adding Attributes
- Select the class
- In the UML section, find Attributes — a multi-line editor with one attribute per line
- Click + (or press
Cmd+L) to add a new attribute, then type its details
Attribute Syntax
Attributes follow this format: visibility name : type
Visibility Modifiers:
| Symbol | Meaning | Description |
|---|---|---|
+ | Public | Accessible from anywhere |
- | Private | Accessible only within the class |
# | Protected | Accessible within class and subclasses |
~ | Package | Accessible 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
- Select the class
- In the UML section, find Operations — a multi-line editor with one operation per line
- Click + (or press
Shift+Cmd+L) to add a new operation, then type its 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
| Type | Line Style | Arrow | Use Case |
|---|---|---|---|
| Association | Solid line | Open arrow | General relationship |
| Dependency | Dashed line | Open arrow | "Uses" relationship |
| Inheritance | Solid line | Hollow triangle | "Is-a" relationship (extends) |
| Realization | Dashed line | Hollow triangle | Interface implementation |
| Aggregation | Solid line | Hollow diamond | "Has-a" (weak ownership) |
| Composition | Solid line | Filled diamond | "Has-a" (strong ownership) |
Creating Relationships
- Press
Rto activate the Relationship tool - Click on the source class
- Drag to the target class
- Release to create the connection
- Use the Inspector's UML section to set the Relationship Type — the line style and arrowheads follow the type
Relationship Labels
Select a relationship and set its labels in the Inspector's UML section:
- Label - Describes the relationship (e.g., "manages", "contains")
- Multiplicity - Source and Target values indicating how many instances (e.g., "1", "0..", "1..")
Best Practices
- Keep it simple - Don't try to model everything; focus on key classes
- Use stereotypes - Clearly mark interfaces and abstract classes
- Show key relationships - Not every association needs to be shown
- Consistent naming - Use PascalCase for classes, camelCase for members
- Group related classes - Use visual proximity to show logical groupings