Problem framing
Members borrow books, reserve unavailable titles, pay fines. Tests catalog/inventory split, loan lifecycle, and waitlist notification (Observer).
| Entity | Responsibility |
|---|---|
Book | Catalog record: title, ISBN, author (bibliographic) |
BookItem | Physical copy: barcode, rack location, availability |
Member | Account, borrow limit, fine balance |
Loan | Links member + bookItem + due date |
Reservation | Queue when no copy available |
Library / LibraryFacade | Orchestrates search, lend, return, reserve |
Catalog vs inventory
One Book (ISBN) maps to many BookItem copies. Search operates on catalog; lending operates on available items. This mirrors Fowler's Catalog vs Inventory — never conflate "Harry Potter exists" with "copy #47 is on shelf 3."
Key flows
Lend — find available BookItem for ISBN → create Loan → mark item unavailable. Reserve — if no copy, add Reservation to queue. Return — close loan, compute fine if overdue, mark available, notify first reserver (Observer or explicit ReservationService.notifyNext()).
Search extensibility
SearchCriteria (author, title, ISBN) with BookCatalog.search(criteria) — new filters add criteria fields or a Strategy, not edits to every caller. Keeps catalog queries OCP-compliant.
Senior-level signal
Model fines in a FineCalculator strategy (flat daily rate vs grace period). State M:N explicitly: one member, many loans; one book, many items. Defer: full-text search, multi-branch libraries, concurrent holds — name them as extensions.
Where this goes next
Elevator System combines state machines with scheduling Strategy — multiple actors competing for a shared resource, like parking spots but with temporal ordering.
Further Reading
Practice Tasks (Optional)
Design or implement locally in any language — no autograding. Focus on class structure, extensibility, and being able to explain trade-offs out loud.
- Design lend and reserve flows40m
Model Book (title, ISBN), BookItem (barcode, copy), Member, Loan, Reservation. Walk through: member reserves unavailable book → book returned → member notified. 6–8 classes.