Foundations
Objects and responsibilities
Assign behavior to the object that owns the relevant state.
Understand the problem
Model use cases before class hierarchies. Prefer cohesive objects with narrow interfaces. Protect invariants through methods rather than allowing arbitrary public-field updates.
Make it concrete
A Reservation exposes confirm and cancel operations rather than a writable status field.
Trade-offs and pitfalls
Too many tiny abstractions can make a simple domain harder to follow.
Check your understanding
Model a parking facility with spots, tickets, and pricing policies.
Practice this topic