Fundamentals 5 min read

Understanding UML Class Diagram Relationships: Generalization, Realization, Aggregation, Composition, Association, and Dependency

This article explains how to correctly draw UML class diagrams by describing the six main relationship types—generalization, realization, aggregation, composition, association, and dependency—using clear examples and visual illustrations to help readers understand and apply each relationship in software modeling.

Full-Stack Internet Architecture
Full-Stack Internet Architecture
Full-Stack Internet Architecture
Understanding UML Class Diagram Relationships: Generalization, Realization, Aggregation, Composition, Association, and Dependency

In team collaborations, meetings often rely on diagrams, especially flowcharts, sequence diagrams, and class diagrams; mastering class diagrams clarifies business logic and improves meeting efficiency. This guide walks you through drawing accurate class diagrams.

The example scenario illustrates a company with departments, developers (code farmers), computers, and mobile devices, highlighting various relationships among them.

Generalization (is‑a) relationship denotes an inheritance hierarchy where a subclass is a type of its superclass. For example, a Mac is a kind of computer. It is represented by a solid line with a hollow arrow.

Realization (implements) relationship connects an interface or abstract class to a concrete class, shown with a dashed line and a hollow arrow. For instance, concrete classes implement the Readable or Printable interfaces.

Aggregation relationship is depicted by a line with a hollow diamond arrow, indicating a weak whole‑part connection. In the example, a developer belongs to a department, but the developer can exist independently if the department is dissolved.

Composition relationship uses a solid diamond arrow, representing a strong dependency where parts cannot exist without the whole. If the company ceases, its departments disappear as well.

Association relationship is shown by a simple solid line (optionally with an arrow) to indicate a static connection between classes, such as a phone being part of a developer’s equipment, which does not change with the developer’s work status.

Dependency relationship is represented by a dashed line with an arrow, describing a runtime usage relationship; for example, a developer uses a Mac only during work, which is reflected in code via constructors or method parameters.

Review : Re‑examine the opening diagram now that you understand each line and arrow; accurate line types are crucial when drawing UML diagrams.

Mnemonic poem to remember the symbols:

实箭泛化虚实现

虚线依赖实关联

空菱聚合实组合

项目沟通图常见

Have you mastered these UML class diagram relationships?

modelingsoftware designUMLRelationshipsclass diagramGeneralization
Full-Stack Internet Architecture
Written by

Full-Stack Internet Architecture

Introducing full-stack Internet architecture technologies centered on Java

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.