Module 01 · Object thinking · Drill
Object thinking drill
Scenario prompts that check whether object thinking is usable under pressure. Answer out loud, then compare.
0 of 4 graded
Prompt 1
A food-delivery codebase has Order, Restaurant and Rider classes that are only fields with getters and setters, and an OrderManager of 3,000 lines that checks every rule. Redesign the responsibilities: which rules move into which objects, and what stays in a service?
Prompt 2
Payments support card, wallet and bank transfer, and each can be one-off or recurring, with optional fraud screening. The current design has a subclass per combination (CardRecurringScreenedPayment and so on, 12 classes). Redesign with composition and show how adding a new method and a new schedule work.
Prompt 3
Define the contract for a SeatInventory interface used by a booking service, with an in-memory implementation for tests and a database implementation in production. Cover holding seats, confirming, releasing, concurrency and failure, and explain how you keep the two implementations equivalent.
Prompt 4
A billing module passes amounts as double, currency as String, dates as String and customer ids as long. List the bugs this invites and redesign the key types as value objects, including how they are persisted and serialised.