CSE Roadmap

Core tier · about 4 hours · 6 parts

Part 2 of 6 · 2 min read

Requirements

Titles, copies, members, loans and holds.

Think of the desk at a small library. A member asks for a title. The librarian does not hand over "the title". She hands over one physical copy, writes the member's name and a due date on a slip, and puts the slip in a box. If every copy is out, she writes the member's name on a waiting list. The slip is a loan. The waiting list is the holds.

Questions and the answers assumed here:

  1. What does the library hold? Titles, each with one or more physical copies.
  2. What can a member do? Search, borrow, return, renew and place a hold.
  3. How long is a loan? 14 days (made up). A renewal adds 7 days, once.
  4. How many loans at once? Three per member.
  5. What happens when all copies are out? The member joins a first-come first-served queue for that title.
  6. What if a book is late? A fine of 2 per late day, capped at 50 (made up). Unpaid fines block new loans.
  7. Out of scope: reference-only books, staff roles, payments, and e-books.

The numbered requirements:

  • R1. A member may hold at most three open loans, and not two of the same title.
  • R2. A loan lasts 14 days, and may be renewed once for 7 more days.
  • R3. A renewal is refused if the loan is overdue or if another member is waiting for the title.
  • R4. When no copy is free, a borrow request puts the member in the hold queue for that title.
  • R5. A copy that comes back is reserved for the first member in the queue.
  • R6. A late return creates a fine, and a member with an unpaid fine cannot borrow.
  • R7. Search finds titles by words in the title or author.

The nouns are title, copy, member, loan, hold, fine and catalogue. The key observation is the first: a title and a copy are different things. The title ("Effective Java") is information. A copy is an object on a shelf that is either in or out. Holds are placed on titles and loans are made of copies. If both are one class, one row cannot say "three copies, one free", and the queue has nothing to attach to.

Entity and value (recap)

A value is defined by its content, and an entity has an identity that stays while its details change.

Example: Book (a title with an ISBN) is a value, and Copy is an entity that goes on and off loan.

Check yourself: 1. What is the difference between a title and a copy? 2. Which two things block a renewal? 3. Why is a hold placed on a title and not on a copy?