Card 09/ 10

ExerciseDifficulty: Intermediate1 min

Practice: Picking a Pattern for Four Features

A job status page, a chat, a live score and a payment confirmation.

Choosing a communication pattern by who sends and how soon is practised here on four features from one product. Decide a pattern for each, with one sentence of reasoning, before opening the answers.

The brief. A sports club runs one web app.

  1. Members export their match history as a file, which takes a minute or two to build; the page shows when it is ready.
  2. Team members chat with each other during a match.
  3. Fans watch the live score of the current match update in the browser.
  4. Members pay their annual fee through a payment provider, and the club's system must mark them as paid.
Check your choices
  1. Short polling. A delay of a few seconds does not matter, and only a handful of members export at a time, so a request every five seconds is cheap.
  2. WebSockets. Both sides send often, and each message is small.
  3. Server-sent events. Only the server sends, news must arrive at once, and the browser reconnects and resumes by itself.
  4. A webhook. The payment provider has the news; it calls the club's endpoint, which verifies the signature, records the event id, and replies at once.