Class Diagram

Published: (January 1, 2026 at 03:57 PM EST)
2 min read
Source: Dev.to

Source: Dev.to

Overview

A class diagram is the backbone of object‑oriented modeling—it shows how different entities (people, things, and data) relate to each other and represents the static structure of a system.
It describes the attributes, operations, and constraints of classes and can be mapped directly to object‑oriented languages.

Purpose of a Class Diagram

  • Analyze and design the static view of an application.
  • Describe the responsibilities of a system.
  • Provide a base for component and deployment diagrams.
  • Support forward and reverse engineering.

Class Representation

A class is depicted as a rectangle divided into three horizontal sections:

  1. Name – the class name (e.g., Flight).
  2. Attributes – the properties of the class.
  3. Operations – the methods of the class.

Class diagram example

Types of Relationships

Association

An association links two classes that need to communicate.

  • Bidirectional (default): both classes are aware of each other.
  • Unidirectional: navigation is allowed only in one direction.

Association example

Multiplicity

Multiplicity specifies how many instances of a class participate in a relationship (e.g., 0..*, 2..4). It is shown as adornments on the association line.

Aggregation

A special form of association representing a “whole‑part” relationship where the part can exist independently of the whole.
Example: An Aircraft can exist without an Airline.

Composition

A stronger whole‑part relationship where the part’s lifecycle depends on the whole.
Example: A WeeklySchedule is composed within a Flight; when the Flight ends, the WeeklySchedule is destroyed.

Generalization

Generalization combines similar classes into a more general superclass, highlighting commonalities.
Example: Crew, Pilot, and Admin are all specializations of Person.

Dependency

A dependency indicates that one class (the client) uses or depends on another class (the supplier).
Example: FlightReservation depends on Payment.

Abstract Class

An abstract class is identified by rendering its name in italics.
In the diagram below, Person and Account are abstract classes.

Abstract class example

Additional Resources

  • For more on sequence diagrams, see:
Back to Blog

Related posts

Read more »

Extensibility: The '100% Lisp' Fallacy

markdown So, I’ve seen some articles promoting Emacs‑like editors written in Lisp languages, and one of the most common arguments seems to be: > “It’s written i...