Fundamentals 7 min read

Mastering UML Class Diagrams: Key Symbols and Relationships Explained

This article introduces UML as a standardized visual modeling language, focusing on commonly used class, sequence, and state diagrams, and explains the symbols and relationships—such as dependency, generalization, association, aggregation, and composition—along with practical examples and tool recommendations for effective software design.

Programmer DD
Programmer DD
Programmer DD
Mastering UML Class Diagrams: Key Symbols and Relationships Explained

Unified Modeling Language (UML) is a visual modeling language adopted as an international standard for object‑oriented modeling in 1997. It provides simple, unified, graphic representations that convey both static and dynamic aspects of software design.

UML supports all phases of software development, facilitating communication, reducing design time, and lowering development costs. It is applicable to general systems as well as parallel and distributed system modeling.

Class Diagram

A class represents a set of objects sharing the same attributes, methods, and relationships. In UML, a class is depicted as a rectangle divided into three compartments: the class name, its attributes, and its operations. Abstract classes are shown in italics.

The following example illustrates various relationships using animal classes:

Animal is a class that depends on oxygen and water.

Bird inherits from Animal, so Bird is a type of Animal.

Bird and Wing have a composition relationship: a bird has two wings.

Goose, Duck, and Penguin inherit from Bird.

Goose flock is an aggregation of geese.

Penguin has an association with Climate because it depends on climate.

Goose implements the Flying interface.

Donald Duck inherits from Duck.

Class

Classes are drawn as three‑section rectangles: the top for the name, the middle for fields/attributes, and the bottom for methods. Abstract classes use italic text.

Package

A package groups related elements and is shown as a tabbed rectangle containing the package name and its contents.

Interface

An interface defines operations without attributes and has no visible associations.

Relationship

Dependency

Dependency (shown as a dashed arrow) indicates that one class uses or calls another class.

Generalization

Generalization (solid line with a hollow triangle) represents inheritance, with the arrow pointing toward the parent class.

Association

Association (solid line with a double‑headed arrow) denotes a bidirectional relationship between two classes.

Aggregation

Aggregation (solid line with a hollow diamond) is a special form of association representing a whole‑part relationship where parts can exist independently.

Composition

Composition (solid line with a filled diamond) is a stronger whole‑part relationship where parts cannot exist without the whole.

Visibility symbols in class diagrams: + public - private # protected

Underlined attributes indicate static members, and the format methodName(parameters):ReturnType describes methods.

Tool Recommendation

If you use IntelliJ IDEA, you can view UML diagrams directly. Understanding the relationships above helps interpret the generated diagrams. Alternatively, you can use tools like YU​Tu for drawing UML diagrams.

References

Baike: https://baike.baidu.com/item/统一建模语言/3160571

Diagram source: 大话设计模式案例

Images: sourced from YU​Tu

YU​Tu: supports various diagram types

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

ModelingUMLRelationshipsClass Diagram
Programmer DD
Written by

Programmer DD

A tinkering programmer and author of "Spring Cloud Microservices in Action"

0 followers
Reader feedback

How this landed with the community

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.