members · staff · paper loan bookweb app1# user story2As a member, I want to3borrow a book, so that4I can read it at homeloan servicedatabase1# interface2borrow(member, book) -> Loan3search(text) -> list[Book]1# functional2borrow, return, search3a loan lasts 21 days1# data model2Book(id, title)3Member(id, name)4Loan(book, member, due)1# non-functional2fast: search under 1 s3cheap: under $20/month4safe: passwords hashed1# design doc2goals + non-goals3the design4alternatives1# constraints2Python, 2 developers3live in 8 weeksSQLitePostgreSQL
Left: the problem and the requirements (users, story, functional, non-functional, constraints)Right: the design (components, interface, data model) and how it is written downChips: a requirement or a call moving to the part that handles itRequirements on the left: the users, a user story, the functional and non-functional requirements and the constraints. The design on the right: three components wired in a row, the interface they agree on, the data model, the design doc and two database alternatives. Chips fly from each requirement onto the component that meets it, the data model's tables move into the database, a borrow() call travels from the web app through the loan service to the database and a Loan comes back, and a check mark settles on the chosen database. Real projects loop: building often uncovers new requirements, so the stories, the design and the doc change as you learn. The figure shows one pass, in order.

The problem

  1. Before any code, understand the problem. A small library keeps its loans on paper: members cannot see if a book is in, and staff chase late books by hand. Ask who will use the system, and what goes wrong for them today.

Requirements

The design

Write it down

What happens

;; step 1/10 · problem
example   a small library-loan app
problem   loans are kept on paper
user      a member     wants to borrow books and see if one is in
user      a librarian  wants to see who has which book and when it is due
ask first: who uses it, and what hurts today?

The library app is an invented example. Its numbers (21-day loans, under $20 a month, 2 developers, 8 weeks) are requirements we chose for it, not facts about libraries. Real projects loop: building often uncovers new requirements, so the stories, the design and the doc change as you learn. The figure shows one pass, in order.