Software Architecture & Modeling
UML Notation Guide
16 min read • Updated October 2026

UML Class Diagrams: Software Architecture Notation & GoF Patterns

The definitive reference for Unified Modeling Language (UML) class diagrams: class anatomies, visibility notation, the 6 core structural relationships, and pattern mappings.


1. The 6 Core UML Relationships Blueprint

Understanding the precise arrows and lines in UML diagrams is crucial for technical interviews and architectural documentation:

+-----------------------------------------------------------------------------------------+
|                         THE 6 ESSENTIAL UML CLASS RELATIONSHIPS                         |
+-----------------------------------------------------------------------------------------+

  1. Generalization (Inheritance):
     [ SubClass ] ─────────────────────────▷ [ SuperClass ]
     - Solid line with closed hollow triangle arrow pointing to parent class.
     - "is-a" relationship (e.g., Dog is-a Animal).

  2. Realization (Interface Implementation):
     [ ConcreteService ] ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄▷ [ <<interface>> Service ]
     - Dashed line with closed hollow triangle arrow pointing to interface.
     - "implements" contract.

  3. Dependency ("uses-a"):
     [ OrderService ] ┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄> [ PaymentCalculator ]
     - Dashed line with open arrowhead.
     - Transient usage: parameter in a method or local variable.

  4. Association ("references"):
     [ Customer ] ─────────────────────────> [ OrderHistory ]
     - Solid line with open arrowhead.
     - Persistent reference stored as a field/attribute.

  5. Aggregation ("weak part-whole"):
     [ Department ] ◇──────────────────────> [ Professor ]
     - Solid line with open hollow diamond at container end.
     - Part can exist independently if whole is destroyed.

  6. Composition ("strong part-whole"):
     [ Order ] ◆───────────────────────────> [ OrderLineItem ]
     - Solid line with filled solid diamond at container end.
     - Part lifecycle is bound to whole: destroying Order destroys items.

2. Class & Interface Box Anatomy

A standard UML class diagram box contains three horizontal compartments:

Visibility Notation Symbols
  • + Public: Accessible to any class.
  • - Private: Accessible only within this class.
  • # Protected: Accessible within class and subclasses.
  • ~ Package / Default: Accessible within the same package.
  • _ Underline: Denotes static attributes or static methods.
  • Italics: Denotes abstract classes or abstract methods.
Multiplicity & Cardinality
  • 0..1 Zero or one instance (optional).
  • 1 Exactly one instance (mandatory).
  • * or 0..* Zero or many instances.
  • 1..* One or many instances (at least one required).
  • m..n Specific range between m and n instances.

3. UML Relationship Comparison Matrix

Clear distinctions across coupling strengths and lifecycle bindings:

RelationshipVisual UML SymbolCoupling StrengthLifecycle BindingGoF Pattern Example
Generalization───▷ (Solid + Hollow Triangle)Very High (Inheritance)Compile-time class hierarchyTemplate Method, Factory Method
Realization┄┄┄▷ (Dashed + Hollow Triangle)Medium (Interface contract)Loose decoupling via polymorphismStrategy, State, Command
Composition◆─── (Solid + Filled Diamond)High (Cascading ownership)Child dies when parent diesComposite, Decorator
Aggregation◇─── (Solid + Hollow Diamond)Medium (Container has parts)Parts survive parent destructionFlyweight, Object Pool
Dependency┄┄┄> (Dashed + Open Arrow)Weakest (Transient method call)No lifecycle or field referenceAbstract Factory client usage

Frequently Asked Questions (UML Class Diagrams)

What is the critical difference between Aggregation and Composition in UML?

Both represent 'has-a' part-whole relationships. In Aggregation (represented by an open hollow diamond ◇), the child parts can exist independently of the parent container (e.g., a Department has Professors; if the Department closes, Professors still exist). In Composition (represented by a filled solid diamond ◆), the child lifecycle is strictly tied to the parent: destroying the parent immediately destroys the child parts (e.g., an Order has OrderLineItems; deleting the Order deletes its line items).

What are the visibility symbols in UML class diagrams?

The four standard visibility notations are: '+' indicates Public access; '-' indicates Private access; '#' indicates Protected access (accessible within class and subclasses); and '~' indicates Package/Default access (accessible within the same namespace or package).

How is Realization visually distinguished from Generalization in UML?

Generalization (class inheritance) is drawn with a SOLID line ending in a closed hollow triangle arrow pointing to the superclass. Realization (interface implementation) is drawn with a DASHED line ending in the same closed hollow triangle arrow pointing to the interface.

Apply UML Diagrams Across All 23 GoF Patterns

Explore interactive class diagrams, sequence workflows, and modern Java 21 code for Creational, Structural, and Behavioral patterns.