If you've ever stared at a UML class diagram and felt lost about what all those boxes, arrows, and symbols actually mean, you're not alone. Class diagrams are one of the most widely used diagrams in software engineering, but the notation can feel like learning a new language. Understanding class diagram symbol meanings helps you communicate system designs clearly with your team, read existing diagrams faster, and create your own with confidence. This guide breaks down every major symbol, explains what it means, and shows real examples so you can apply it right away.
What is a UML class diagram?
A UML class diagram is a type of static structure diagram used in Unified Modeling Language (UML) to describe the structure of a system. It shows classes, their attributes, methods, and the relationships between them. Think of it as a blueprint for object-oriented software. Developers, architects, and technical leads use class diagrams during system design, code reviews, and documentation to make sure everyone shares the same understanding of how a system is built.
Class diagrams fall under the broader family of UML diagrams. If you're working with other diagram types, our UML notation codes reference guide covers a wide range of diagram syntax in one place.
What do the basic class diagram symbols mean?
Every class in a UML class diagram is drawn as a rectangle divided into three sections. Each section has a specific purpose:
- Top section Class name: The name of the class, written in bold and centered. If the class is abstract, the name appears in italics.
- Middle section Attributes: Lists the properties or fields of the class. Each attribute follows this format:
visibility name: type. For example:- name: String - Bottom section Methods (operations): Lists the class methods. Format:
visibility methodName(parameters): returnType. For example:+ getName(): String
Visibility markers explained
Visibility symbols appear before each attribute or method name. They control who can access that member:
+(plus sign) Public. Accessible from anywhere.-(minus sign) Private. Accessible only within the class itself.#(hash/pound) Protected. Accessible within the class and its subclasses.~(tilde) Package. Accessible within the same package.
These four symbols show up constantly, so memorizing them early saves a lot of confusion later.
How do you read relationship lines and arrows between classes?
Relationships are where most people get confused. The lines connecting classes are not all the same each type of line, arrow, and notation carries a distinct meaning.
Association (solid line)
A plain solid line between two classes means they are associated one class knows about or uses the other. If the line has an arrowhead, it shows the direction of the relationship. For example, a Customer class pointing to an Order class means a customer places orders.
Aggregation (empty diamond ◇)
Aggregation represents a "has-a" relationship where one class contains another, but both can exist independently. The diamond sits on the side of the whole (container). Example: A Department has many Employees, but employees can exist without the department.
Composition (filled diamond ◆)
Composition is a stronger form of aggregation. The filled diamond means the contained class cannot exist without the container. Example: A House is composed of Room objects. If the house is destroyed, the rooms are too.
Inheritance / Generalization (empty arrow ▷)
An arrow with a hollow, triangular head pointing from a child class to a parent class means inheritance. The child class extends the parent. Example: Dog → Animal means Dog inherits from Animal.
Realization / Implementation (dashed arrow ▷)
A dashed line with a hollow arrowhead means a class implements an interface. Example: A PaymentProcessor class realizes an IPayment interface.
Dependency (dashed arrow →)
A dashed line with an open arrowhead shows that one class depends on another temporarily usually as a method parameter or local variable. Example: A ReportGenerator depends on a DataSource only when generating a report.
What do multiplicity numbers mean on class diagrams?
You'll often see numbers or symbols near the ends of a relationship line. These are multiplicity notations that tell you how many instances of one class relate to another.
1Exactly one0..1Zero or one (optional)Zero or more1..One or morenExactly n (a specific number)
For example, writing 1 next to Customer and next to Order means one customer can have many orders, but each order belongs to exactly one customer.
What do the common UML stereotypes and symbols look like?
Beyond the basics, class diagrams use additional symbols and stereotypes to add meaning:
«interface»Indicates the class is an interface (often drawn with a dashed border or with the stereotype above the name).«abstract»Marks a class as abstract. Alternatively, the class name is written in italics.«enumeration»Shows that the class is an enum type. Values are listed in the attributes section.«static»(underlined members) An underlined attribute or method means it belongs to the class itself, not an instance.{readOnly}A constraint indicating the attribute cannot be modified after initialization.{ordered}Specifies that a collection of objects has a defined order.
For more on UML syntax across different diagram types, you may find the activity diagram symbols cheat sheet useful for comparing notations.
Can you show a real example of a class diagram?
Let's build a simple example an e-commerce order system:
Customer(class): Attributes:- name: String,- email: String. Methods:+ placeOrder(): OrderOrder(class): Attributes:- orderId: int,- date: Date. Methods:+ getTotal(): doubleOrderItem(class): Attributes:- quantity: int,- price: double. Methods:+ getSubtotal(): doubleProduct(class): Attributes:- name: String,- sku: String
Relationships in this example:
CustomertoOrder: One-to-many association (1to)OrdertoOrderItem: Composition (filled diamond on Order side,1to1..). If an order is deleted, its items are deleted too.OrderItemtoProduct: Association with multiplicityto1. Each order item references one product.OrderimplementsIPrintableinterface (dashed arrow with hollow triangle)
This small model already uses class names, attributes, methods, visibility symbols, multiplicity, composition, association, and realization. That covers most of what you'll encounter in day-to-day diagrams.
What mistakes do people make with class diagram notation?
After reviewing hundreds of class diagrams, here are the most common errors:
- Confusing aggregation and composition. If both classes can live independently, use aggregation (empty diamond). Only use composition when the contained object's lifecycle depends on the container.
- Forgetting visibility markers. Leaving off
+,-, or#makes the diagram ambiguous. Every attribute and method should show its access level. - Using inheritance when they mean association. Just because Class A uses Class B doesn't mean A should extend B. Inheritance means "is-a." Association means "uses" or "has."
- Overcomplicating the diagram. Including every single class in a large system makes the diagram unreadable. Focus on the most important 10–15 classes for any given view.
- Mixing up arrow directions. The arrowhead on an inheritance line points to the parent (the more general class), not the child.
- Ignoring multiplicity. Without multiplicity, a relationship tells only half the story. Always clarify whether the relationship is one-to-one, one-to-many, or many-to-many.
When should you use a class diagram instead of other UML diagrams?
Class diagrams show structure, not behavior or sequence. Use them when you need to:
- Plan the architecture of an object-oriented application before coding
- Document the data model of an existing codebase
- Communicate class responsibilities and relationships to a team
- Identify missing classes or misplaced logic during design reviews
If you need to show how objects interact over time, a sequence diagram is more appropriate. If you need to model workflows or business processes, an activity diagram works better. For system-level component interactions, check out our guide on UML component diagram syntax and best practices.
What tools can you use to draw class diagrams?
You don't need to draw these by hand. Here are tools developers actually use:
- PlantUML Write text-based UML and generate diagrams automatically. Free and open source.
- draw.io (diagrams.net) Free web-based diagramming tool with built-in UML templates.
- Lucidchart Cloud-based diagramming with UML support and team collaboration features.
- Enterprise Architect Professional UML modeling tool used in larger organizations.
- IntelliJ IDEA / Visual Studio Many IDEs can generate class diagrams directly from your source code.
PlantUML is especially useful if you want your diagrams version-controlled alongside your code. You write the class definitions in plain text, and the tool renders the visual diagram.
Quick reference checklist for class diagram symbols
Use this checklist whenever you're reading or creating a class diagram:
- ☐ Class name is in the top compartment (italic if abstract)
- ☐ Attributes show visibility (
+ - # ~), name, and type - ☐ Methods show visibility, name, parameters, and return type
- ☐ Static members are underlined
- ☐ Aggregation uses an empty diamond (◇)
- ☐ Composition uses a filled diamond (◆)
- ☐ Inheritance uses a solid line with a hollow arrow pointing to the parent
- ☐ Interface realization uses a dashed line with a hollow arrow
- ☐ Dependency uses a dashed line with an open arrow
- ☐ Multiplicity labels (1, , 0..1, 1..) appear on relationship ends
- ☐ Stereotypes like
«interface»and«enumeration»are used where applicable - ☐ The diagram is focused and readable not trying to show every class at once
Print this list, keep it next to your workspace, and you'll internalize the symbols faster than you'd expect. For the full set of UML notations across all diagram types, see the complete UML notation reference guide.
Sequence Diagram Notation Explained for Beginners
Uml Component Diagram Syntax Rules and Best Practices
Uml Notation Codes Reference Guide for Software Architects
Activity Diagram Standard Symbols Cheat Sheet
Iec vs Ansi Circuit Diagram Notation: Key Differences Explained
How to Read Iec 60617 Electrical Schematic Codes