# UML timing diagram A timing diagram plots how a participant's state changes over time. It is the UML equivalent of a hardware waveform, and it suits protocols where duration and ordering both matter. Rare, and exactly right on the occasions it applies. --- ## When to draw one * Protocols with timing constraints or timeouts. * Explaining a race condition. * Documenting how long a participant stays in each state. --- ## What is on the diagram | **Element** | **Meaning** | | ------------ | --------------------------------------------------- | | Lifeline | One participant, with its states stacked vertically | | State change | A step in the line at the moment it changes | | Time axis | Horizontal, with real units | | Constraint | A duration annotation between two points | --- ## A worked example Two participants, their states, and a timeout: ![UML timing diagram](https://help.gocapable.com/images/att1417379849.svg) The source, which you can paste into a new diagram and edit: ``` @startuml robust "Client" as C concise "Connection" as N @0 C is Idle N is Disconnected @100 C is Connecting N is Handshaking @250 C is Connected N is Established @900 C is Waiting @1400 C is Timeout N is Disconnected @1500 C is Idle C@250 <-> C@900 : request in flight C@900 <-> C@1400 : 500ms timeout window @enduml ``` --- ## A few things that catch people out * Use real time units on the axis. A timing diagram with no units is a state diagram drawn sideways. * Annotate the constraints; the durations are the reason to draw one. * robust shows discrete states, concise shows a compact single line. Mix them deliberately. --- ## Related [Class diagramTypes, fields and the relationships between them.](https://help.gocapable.com/diagrams/class-diagram.html) [Sequence diagramWho calls whom, in what order.](https://help.gocapable.com/diagrams/sequence-diagram.html) [UML diagramsBack to the UML overview.](https://help.gocapable.com/diagrams/uml-diagrams.html) --- _Four types cover most of it._