Modul 4 von 16 · 📖 5 min Lesezeit · ⏱ 30 min gesamt

FI-AE 04 UML — Klassen- und Sequenzdiagramme (EN)

Inhaltsverzeichnis (6 Abschnitte)
  1. Concepts and Background
  2. Architecture Diagram
  3. Practical Steps
  4. Common Pitfalls
  5. Further Resources
  6. Knowledge Check

FI-AE 04 UML — Class and Sequence Diagrams

UML (Unified Modeling Language) is the standard for modeling software systems. In this module, we focus on class and sequence diagrams, which are fundamental for the structured analysis and design of object-oriented systems. You will learn how to graphically represent classes, their attributes, methods, and relationships, as well as how to model the temporal sequence of object communication in scenarios.

Mastery of these diagrams is essential for clear communication of system architectures and processes between developers, analysts, and stakeholders. They form the basis for consistent implementation and maintenance of complex software systems.

Concepts and Background

Classes
The fundamental building blocks of object-oriented models that encapsulate data (attributes) and functionality (methods). A class field in UML typically consists of three sections: class name, attributes, and methods.
Relationships
The interactions between classes that define their structure and behavior. Important relationship types are association, aggregation, composition, and inheritance, which represent different forms of dependency and hierarchy.
Sequence Diagrams
Show the temporal sequence of messages between objects in a specific scenario. They focus on interaction over time and are particularly suitable for representing processes and workflows.
Activity Diagrams
Model the flow of activities and processes as flowcharts. They are used to represent business processes, workflows, or algorithms and show decision points, parallelism, and iterations.

Architecture Diagram

classDiagram
  class Customer {
    +customerId: int
    +name: string
    +email: string
    +placeOrder()
    +contact()
  }
  
  class Order {
    +orderId: int
    +date: date
    +status: string
    +calculateTotalPrice()
    +cancel()
  }
  
  class Product {
    +productId: int
    +name: string
    +price: decimal
    +stock: int
    +checkAvailability()
  }
  
  class Payment {
    +paymentId: int
    +amount: decimal
    +date: date
    +paymentMethod: string
    +processPayment()
  }
  
  Customer "1" -- "0..*" Order : has
  Order "1" -- "1..*" Product : contains
  Order "1" -- "1" Payment : causes

Practical Steps

  1. Identify the essential classes of your system and define their attributes and methods. Start with the core objects that represent your system's domain.
  2. Define the relationships between classes by graphically representing associations, aggregations, compositions, and inheritance relationships. Pay attention to the correct use of multiplicity notations.
  3. Create a sequence diagram for a critical use case to visualize the interaction between objects over time. Start with the initiating object and show the message flow until the scenario completes.
  4. Model complex business processes with activity diagrams to represent decision points, parallelism, and iterations. Use swimlanes to clarify responsibilities for different actors.
  5. Validate your models through reviews with stakeholders and implement the classes according to the UML diagram in your programming language of choice.

Common Pitfalls

Further Resources

Knowledge Check

Four questions for self-assessment. Click on each question to see the correct answer and explanation.

What is the main function of classes in UML?
  • A) Representation of data flows between systems
  • B) Encapsulation of data and functionality in object-oriented models
  • C) Modeling of temporal sequences and workflows
  • D) Visualization of database structures

Correct Answer: B. Classes encapsulate data (attributes) and functionality (methods), while data flows are represented in activity diagrams and temporal sequences in sequence diagrams.

Which relationship between classes would most likely represent a "has-a" relationship in the real world?
  • A) Inheritance
  • B) Composition
  • C) Generalization
  • D) Realization

Correct Answer: B. Composition represents a strong "has-a" relationship where the part cannot exist without the whole, while inheritance and generalization represent "is-a" relationships.

What is the main difference between sequence and activity diagrams in UML?
  • A) Sequence diagrams show static structures, activity diagrams show dynamic flows
  • B) Sequence diagrams focus on temporal sequence of messages, activity diagrams on process flows
  • C) Sequence diagrams are only used for technical systems, activity diagrams for business processes
  • D) Sequence diagrams represent object interactions, activity diagrams represent state changes

Correct Answer: B. Sequence diagrams focus on the temporal sequence of messages between objects, while activity diagrams model process flows and business workflows.

What does the multiplicity notation "1..*" in a UML class diagram indicate?
  • A) Exactly one relationship
  • B) Zero or one relationship
  • C) One or more relationships
  • D) Many relationships (more than 10)

Correct Answer: C. The notation "1..*" indicates a minimum of one and a maximum of many (unlimited) relationships, meaning "one or more".