Index

Free, with Google

Keep going, free.

A free account opens lessons 2 and 3 of every track, 33 more lessons, and keeps your progress and review cards on every device.

Start free with Google

Launch price

Open everything on chalk.

Every lesson, board, video, lab and paper, and the full review decks. Yearly is $39/year, or $19.50 for your first year with LAUNCH50, ends 1 Nov, 18:30 UTC.

See plansStart free instead

Module 08 · System Design · Low-level design: classes, properly

Tell everyone who cares (Observer and State)

Tell Everyone Who Cares
Tell Everyone Who Cares · Open board

The model with two views, the book’s watcher list, and the loan state machine with five of nine moves allowed.

Before you start. A design pattern is a named, reusable way of arranging classes. This lesson uses two, and builds on three earlier ideas. From Swap the rule, keep the class (Strategy and Factory), the swappable part (the strategy pattern): an object holds a rule object inside and can be handed a different one, without knowing which. From Five letters, one shop (SOLID), the trap: having to edit code that already worked every time something new is added. From The object that keeps its own rules (encapsulation and invariants), one object guarding its own state, meaning the facts it remembers right now. The example is a library book, and a book remembers three things: where it is, who has it, and who is waiting.

Lesson 40 of 73 in System Design

The rest of this lesson is part of a plan.

A plan opens every lesson, board, video, lab and paper on chalk. Yearly is $39/year, or $19.50 for your first year with LAUNCH50, ends 1 Nov, 18:30 UTC.

See plansAlready a member? Sign in

Or start free: a free account opens lessons 2 and 3 of every track.

In this lesson

  • 1979: a screen that must not lie, and the man who split it
  • A library book: the one who is announced about, and the ones who listen
  • The cost: the subject does not control what happens next
  • The other mess: a book that behaves differently in each situation
  • The map: a state machine
  • Both together: one book, two patterns

Terms it explains: model, view, subject, observers, subscribe, observer, state, state pattern, state machine, current state.

Review System Design