Live Sequence Charts for Mermaid

A step-by-step tutorial. No background needed.

Writing Live Sequence Charts

A Live Sequence Chart is a picture of people, or machines, passing messages to each other. It can tell a story ("here is one way an order at a café can go") or state a rule ("whenever someone pays, they must get their drink"). This tutorial teaches you to write them, one small idea at a time.

You don't need to know anything about programming, diagrams or the notations they grow out of. Every chart in the tutorial is drawn live from the text under it. Change the text and the picture changes with it. Each lesson ends with something to try and a question to check your understanding, and each has a model answer you can open when you are ready.

The same story runs through the whole tutorial: a customer orders a coffee from a barista, and pays at the till. It grows a little in every lesson. The last part reads a chart from the paper that introduced Live Sequence Charts, Damm and Harel's "LSCs: Breathing Life into Message Sequence Charts" (2001).

Part 1: Telling a story

No rules yet. A chart is a picture of something that happened.

  1. 1Who and whenColumns are participants, time runs down the page, and an arrow is a message.
  2. 2Names and wordsGive a chart a title, give participants proper names, add details to messages, and leave notes.
  3. 3What comes before whatEvents on one line happen in order. Between lines, only arrows create order.
  4. 4Waiting or notHand-overs and letters, and letters that cross or overtake each other.
  5. 5The outside worldUse env for messages from, or to, anyone the chart doesn't name.

Part 2: From stories to rules

The core idea of Live Sequence Charts: saying what must happen, and what may.

  1. 6“Can happen” versus “must happen”An existential chart is an example of what can happen. A universal chart is a rule.
  2. 7When does a rule apply?Start a rule with a trigger message, or with a trigger condition.
  3. 8Setting the sceneA prechart says “once this has happened, then this must follow”.
  4. 9Must the story carry on?Each point on a line is hot (the story must move past it) or cold (it may stop there).
  5. 10Must a message arrive?Hot messages must arrive once sent. Cold messages may get lost. Plus “defaults cold” and the temperature cue.
  6. 11Facts and checksVariables hold facts, and conditions check them. A failed hot check breaks the rule; a failed cold check ends it quietly.
  7. 12Saying “never”Forbid a scenario with a prechart that describes it and a check that can never be true.

Part 3: Shaping longer stories

Chapters, repeats, choices, and participants who come and go.

  1. 13ChaptersSubcharts group part of a story. Everyone in one starts it together and finishes it together.
  2. 14RepeatingRepeat a chapter while a check holds, a fixed number of times, or as many times as a variable says.
  3. 15ChoicesUse if … else when exactly one of two things happens.
  4. 16Any order, and the same momentA coregion lets events on one line happen in any order. A simultaneous region makes them one moment.
  5. 17Arrivals and departuresParticipants who join or leave partway through, timers, and helpers that only exist inside one chapter.
  6. 18Watching without showingA chart can watch for messages it doesn't draw, and forbid them while it runs.

Part 4: Putting it together

A full chart from the paper, and what to do when the page complains.

  1. 19Reading a full chartThe rail car from the paper that introduced Live Sequence Charts, one piece at a time.
  2. 20When the page complainsErrors and warnings, the common mistakes, and saving and sharing your charts.