Skip to content
Tutorials Center
My learning

Topics

Lesson 26 of 39 ยท Deployment and Packaging

Timing and Interaction Overview Diagrams

Learn the two least-known UML interaction diagrams: timing diagrams for state changes over time, and interaction overview diagrams that chain scenarios.

UML 2 has four interaction diagrams. Sequence diagrams and communication diagrams are the common ones. The other two, timing diagrams and interaction overview diagrams, are used less often, but each solves a problem the others handle badly. Timing diagrams show exactly when things change, and interaction overview diagrams show how several scenarios are chained. Knowing them completes your toolbox.

Timing diagrams

A sequence diagram orders messages but says nothing about how long anything takes. When timing is the requirement (embedded systems, protocols, real-time control, debouncing a button), you need a timing diagram.

It looks like an oscilloscope or logic analyzer trace:

  • Time runs from left to right along a horizontal axis, with tick marks and units.
  • Each participant (a lifeline) has its own horizontal band. The vertical position inside the band shows its state.
  • A state change is a vertical step at a given time, labeled with the event that caused it.
  • Duration constraints such as {0..5 ms} limit how long a state may last, and time constraints such as {t..t+10ms} bound when an event may occur.
  • Arrows between bands show messages that cause changes in another lifeline.

Two notations exist. The state-line form draws a line that steps between named states. The value-lifeline form draws a band with crossings when a value changes (like a bus). Most examples use the state-line form.

A text sketch for a traffic light and a pedestrian button shows the idea:

TEXT
time (s)     0    10   20   30   40
Light   Red  โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ                โ–ˆโ–ˆโ–ˆโ–ˆ
        Green         โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
        Amber                 โ–ˆโ–ˆ
Button  Idle โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Œ      โ–โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ
        Pressed        โ–โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–Œ
                         ^ press at t = 12 s, light must turn red within {10..20 s}

Most diagramming tools used by developers do not support timing diagrams. If yours does not, use a sequence diagram with notes for time constraints, or draw the waveform in a table or code (the example below does this).

sequenceDiagram
    participant B as Button
    participant C as Controller
    participant L as Light
    B->>C: press (t = 0)
    Note over C: debounce {20 ms}
    C->>L: switchToAmber
    Note over L: Amber {3 s}
    L->>L: switchToRed
    Note over L: Red {10 s}

A sequence diagram with duration notes is a reasonable substitute when no timing diagram is available.

When to use timing diagrams

  • Protocol and hardware interaction: setup and hold times, timeouts, retries.
  • Performance requirements across components: "response within 200 ms of request".
  • Anything with real-time deadlines or periodic behavior (a heartbeat every second).

Interaction overview diagrams

A sequence diagram shows one scenario. A real use case has several: payment accepted, payment rejected, retry. An interaction overview diagram (IOD) is an activity diagram whose nodes are interactions. It shows the flow of control between scenarios with decisions, forks and loops, and each node is itself a small sequence diagram, either drawn inside a frame or referenced with ref.

Elements:

  • Initial and final nodes, decision and merge diamonds, fork and join bars, as in activity diagrams.
  • Interaction occurrence (ref) nodes: a frame labeled ref that points to another interaction.
  • Interaction nodes: a frame labeled sd with a small sequence diagram embedded.

The value of the IOD is the big picture: "first we authenticate, then either order or browse; ordering involves payment, and payment can loop on failure".

flowchart TD
    S(("start")) --> A["ref: Authenticate"]
    A --> D{"valid?"}
    D -->|"no"| A
    D -->|"yes"| M["ref: Browse catalog"]
    M --> O{"checkout?"}
    O -->|"yes"| P["ref: Pay by card"]
    P --> R{"approved?"}
    R -->|"no"| P
    R -->|"yes"| F["ref: Send confirmation"]
    O -->|"no"| E(("end"))
    F --> E

Each box would be a sequence diagram of its own.

Choosing between the interaction diagrams

Question Use
In which order do objects exchange messages? Sequence diagram
Which objects are linked, and what flows over each link? Communication diagram
How does a value or state evolve over time, with limits? Timing diagram
How do several scenarios fit into one flow? Interaction overview diagram

Do not force them. Teams often use only sequence diagrams and an activity diagram, which is fine.

A timing diagram in code

The following script draws the state of a signal over time as text, and checks a duration constraint. It is a quick way to experiment with timing before a tool or hardware is available.

Python Draw a state-over-time trace and check a constraint

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

An interaction overview as a scenario graph

An IOD is a graph of scenarios. The script walks a few random-free paths through it to list the scenarios a test plan must cover.

Python Enumerate scenario paths through an overview

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Each printed path is a candidate end-to-end test. This is one practical reason to draw an overview: it turns a vague flow into a countable set of scenarios.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does a timing diagram emphasize?

    Time is the horizontal axis, and duration or time constraints can be added.
  2. 2. What is an interaction overview diagram?

    It chains scenarios with decisions, forks and loops, using ref frames.
  3. 3. Which requirement is best shown on a timing diagram?

    Response-time and timeout constraints are timing concerns.
  4. 4. What does a ref frame in an overview diagram do?

    An interaction occurrence references a separate interaction, keeping the overview small.

Summary

  • Timing diagrams show state over a time axis, with duration and time constraints.
  • Use them for protocols, hardware, real-time requirements and periodic behavior.
  • Interaction overview diagrams are activity diagrams whose nodes are sequence diagrams.
  • They show how scenarios link up and are a good source for end-to-end test cases.
  • If tools lack these diagrams, use annotated sequence diagrams or code to experiment.

Next: Class Diagrams to Code