Skip to content
IRC-Coding IRC-Coding
UML Class Diagram Sequence Diagram Activity Diagram OCL Cardinality

UML Fundamentals: Diagrams, Relations & Cardinality

Master UML: structural/behavioral diagrams, aggregation, composition, cardinality, OCL, test derivation & exam prep.

S

schutzgeist

1 min read

UML (Unified Modeling Language)

This article is a conceptual explanation of UML – including exam questions, core components, and tags.

In a Nutshell

UML is a standardized visual language for modeling software and systems. It helps to document requirements, design, and communication consistently.

Compact Technical Description

UML separates structure and behavior:

  • Structure diagrams (e.g., class diagram, package diagram, component diagram)
  • Behavior diagrams (e.g., activity diagram, sequence diagram, state diagram)

Relationships:

  • Association
  • Aggregation
  • Composition
  • Generalization

Cardinalities (multiplicities) describe relationships (e.g., 1, 0..1, 0..*). With OCL, constraints can be formally defined (invariants, pre-/postconditions) – tests can be derived from these.

Exam-Relevant Key Points

  • Structure diagrams vs behavior diagrams
  • Relationships correctly: association/aggregation/composition/generalization
  • Cardinalities are a typical IHK exam point
  • OCL for precise conditions → derive tests
  • Model states with guards
  • Version/review/approve models

Core Components

  1. Class/attribute/operation + visibility
  2. Relationships (association, aggregation, composition)
  3. Multiplicities + roles
  4. Packages/namespaces
  5. Components/interfaces
  6. Activity (decision, parallelism)
  7. Sequence (lifeline, message)
  8. State machine (guard, entry/exit)
  9. Stereotypes/profiles
  10. OCL + test derivation

Practical Example (Library)

Class diagram:
Reader 1..* Loan
Medium 1..* Loan
Loan: startDate, endDate

OCL invariant:
endDate > startDate

Advantages and Disadvantages

Advantages

  • Common language for business/technical departments
  • Earlier error detection
  • Better test derivation
  • Clear documentation

Disadvantages

  • Learning curve
  • Risk of overly complex models
  • Loses value without maintenance

Typical Exam Questions (with Short Answer)

  1. Main categories of UML diagrams? Structure diagrams and behavior diagrams.
  2. Aggregation vs composition? Aggregation is weak; composition binds lifecycle.
  3. What is OCL used for? Formal constraints → tests.

Free Response

For the exam: prefer a few diagrams that are correct and consistent. Cardinalities and relationships must match business rules. Models should be versioned and linked to requirements/test cases.

Learning Strategy

  1. Reconstruct a class diagram from a small project.
  2. Create activity and sequence diagrams for a use case.
  3. Practice and justify cardinalities.
  4. Apply consistent naming/cardinalities consistently.

Most Important Sources

  1. https://www.omg.org/spec/UML
  2. https://martinfowler.com/books/uml.html
Back to Blog
Share:

Related Posts