Curriculum

Curriculum

Separate Request Inputs from Stored State

Scenario

A student walks up to the library desk to borrow a book. Some facts come from this new request, and some are already saved in the library system.

Card3
Request Input0
Stored State0

Try it yourself

Sort each item into Request Input or Stored State.

Reveal the explanation
  1. Book barcode scanned at the desk

    Request Input · Sent right now as part of this checkout request.

  2. Reader’s current count of 2 borrowed books

    Stored State · Already saved in the library system before this request arrived.

  3. Reader ID presented for checkout

    Request Input · Identifies who is making this request right now.

Many bugs happen because tests give the request ("Room A at 14:00") but forget to state the starting stored state ("Room A is already occupied").

Your turn

For a room booking check, list two request items and one stored state item.

Common mistake Testing a request without recording the starting schedule state.

Check your work

Request items: room ID and time slot; Stored state: schedule availability map.

Quick check

Why can the exact same request ("Sam asks for Room A at 14:00") return Accept once and Decline later?
Show the answer and reasoning

Correct answer The stored schedule state changed between the two requests

Deterministic programs always give the same answer for the same request + stored state; when the stored state changes, the decision changes.