UML Fundamentals – Diagram Types, Class Diagrams, Sequence Diagrams & OCL
This article is a concept guide to UML – including exam questions and key terms.
In a Nutshell
UML is a standardized visual language for modeling software and systems. It provides structured and behavioral diagrams to document requirements, design, and communication consistently.
Compact Technical Overview
UML separates structure from behavior. Structural diagrams like class and package diagrams describe static elements, while behavioral diagrams such as activity, sequence, and state diagrams show processes and interactions. Key relationships include association, aggregation, composition, and generalization, supplemented by dependencies and realization. Visibility modifiers control access, multiplicities describe cardinalities, and stereotypes and profiles allow domain-specific customization. Textual constraints are formulated using OCL, covering invariants, preconditions, and postconditions.
Exam-Relevant Points
- Structural diagrams: classes, objects, packages, components, deployment
- Behavioral diagrams: activity, sequence, communication, state machines, use cases
- Understand relationships: association, aggregation, composition, generalization, realization, dependency
- Notate cardinalities correctly and align them with business rules
- Use OCL for precise conditions; derive acceptance criteria and tests from them
- Model states with guard conditions and actions; verify security-critical transitions
- Achieve cost savings through early defect detection and improved communication
- Version, review, and approve models; document their relationship to requirements and test cases
Core Components
- Notation elements: class, attribute, operation with visibility
- Relationships: association, aggregation, composition, generalization
- Multiplicities and role names on edges
- Packages, namespaces, import and visibility rules
- Components and interfaces with realization
- Activity elements: action, decision, merge, fork, synchronization
- Interaction elements: lifeline, message, activation in sequence models
- State machine with states, transitions, guards, entry and exit actions
- Profiles, stereotypes, tagged values for domain-specific extensions
- OCL for invariants, preconditions, postconditions, and derived test cases
Practical Example
Domain: Library Loan System
Class Diagram:
Classes: Reader, Medium, Loan
Relationships: Reader to Loan (1 to *), Medium to Loan (1 to *)
Loan has attributes: startDate, endDate, isExtended
Operation: extend() with rule: endDate = endDate + 14 days if Medium is extendable
Sequence: "Borrow Medium"
Actors: Reader, System, Catalog, LoanService
Flow:
1. Reader sends "Borrow Medium" to System
2. System queries Catalog for availability
3. Catalog responds "available"
4. System calls LoanService: create Loan with Reader and Medium
5. LoanService creates Loan and confirms; System reports success
OCL Example:
Context Loan::inv ReturnDateValid: self.endDate > self.startDate
Advantages and Disadvantages
Advantages
- Common language across business and technical teams
- Better analysis and design quality
- Faster test derivation
- Clear documentation, improved maintainability
Disadvantages
- Learning curve and ramp-up effort
- Risk of overly complex models
- Lack of enforcement without process discipline
- Potential misunderstandings if notation is inconsistent
Typical Exam Questions (with Brief Answers)
-
What are the main categories of UML diagrams? Structural diagrams (class, package, component) and behavioral diagrams (activity, sequence, state machine, use case).
-
What is the difference between aggregation and composition? Aggregation is a weak whole-part relationship with no lifecycle binding; composition is a strong relationship where parts share the whole’s lifetime.
-
How is OCL used in UML? For precise formal constraints like invariants, preconditions, and postconditions that translate well into tests.
-
*What do cardinalities 1, , and 0..1 mean? 1 = exactly one element, * = zero to any number, 0..1 = optional single element.
-
How are systems bounded in UML? Via system boundaries in use case diagrams and package/component interfaces.
-
How do you derive test cases from UML? From scenarios in sequence and activity diagrams, and from OCL conditions.
-
When is generalization used? When common properties are factored into a base class, and specializations extend or override them.
-
What makes a correct class diagram for certification exams? Classes with meaningful names, attributes with types and visibility, operations, and relationships with cardinalities and role names.
Key References
- https://www.omg.org/spec/UML
- https://martinfowler.com/books/uml.html
- https://en.wikipedia.org/wiki/Unified_Modeling_Language



