Module 22 · OOP in practice · Drill
OOP in practice drill
Scenario prompts that check whether oop in practice is usable under pressure. Answer out loud, then compare.
0 of 4 graded
Prompt 1
Design the error-handling policy for an order service that calls a payment client, an inventory client and a database. Say which failures are exceptions and which are results, where each is caught, what is retried, and how you avoid leaking connections.
Prompt 2
Pick the collections for an in-memory session manager: look up a session by token on every request, expire the session that times out soonest, list a user's active sessions, and evict the least recently used session when memory is full. Give each operation's cost.
Prompt 3
You are designing a plugin API for exporters (CSV, Parquet, S3, BigQuery) that third parties will implement. Choose between an interface, an abstract class or both, show what goes where, and explain how you will add a 'flush' operation next year without breaking existing plugins.
Prompt 4
A pricing engine is a hierarchy of 40 Promotion subclasses with mutable state, and every new analysis (preview, audit trail, conflict detection) needs a new method on all 40 classes. Propose a redesign that mixes object-oriented and functional styles, and justify it with the expression problem.