Open-Closed Principle in Interviews: Handling a Mid-Design Requirement Change
How to absorb “one more requirement” with minimal blast radius
☰ Jump to section
Twenty minutes into your LLD design, the interviewer smiles: “Also support coupon codes.” Or WhatsApp notifications. Or surge pricing. They are not being cruel — they are testing whether your structure bends or breaks.
That test is the Open-Closed Principle in interview clothing: open for extension, closed for modification. This article shows how to place seams so “one more requirement” stays small.
01What Interviewers Measure with a Twist
- Did you hard-code the volatile decision?
- How many boxes turn red when the twist arrives?
- Can you extend with a new type instead of editing five methods?
- Do you explain the trade-off of the seam you chose?
02Find Volatility Before You Draw
During clarification, ask what is likely to change. Classic volatilities in LLD prompts:
| Domain signal | Likely volatility | Seam to consider |
|---|---|---|
| Multiple providers | Payment / auth / maps | Interface + implementations |
| Multiple channels | Email / SMS / push | Notifier strategy |
| Rules differ by plan/region | Pricing / eligibility | Policy / Strategy |
| Optional extras | Logging, metrics, retry | Decorator |
You cannot abstract everything. Abstract the axes the story emphasizes.
03Worked Mini-Example: Pricing Twist
Initial ask: flat fare for rides. Twist: support surge multipliers at peak hours.
// Fragile
FareService.calculate(distance) {
return distance * RATE;
// later: sprinkle if (peak) everywhere
}
// OCP-friendlier
FareService depends on PricingStrategy
FlatPricing implements PricingStrategy
SurgePricing implements PricingStrategyThe twist adds SurgePricing (and maybe a factory/selector). FareService stays mostly closed.
04Blast Radius Checklist After a Change
- List every type you edited.
- If the list includes stable domain entities for a peripheral rule, your seam was wrong.
- Prefer adding a type over editing a switch.
- Re-run the original use case mentally — OCP is not an excuse to break old paths.
Change One Thing on LLDCanvas drops a new requirement mid-design and scores how small your blast radius stays against an OCP-compliant ideal.
05Five Interview Twists and Low-Blast Responses
| Twist | Bad reaction | Low blast-radius move |
|---|---|---|
| Add a second payment provider | Edit CheckoutService if-else | New PaymentGateway implementation |
| Add retry once on soft failure | Copy retry into every provider | Decorator around PaymentGateway |
| Add student discount | Sprinkle if (student) in fare math | PricingStrategy / discount policy object |
| Audit every state change | Log calls in every mutator | Domain event or auditing interceptor at the seam |
| Support read-only guest mode | Boolean flags across services | Authorization policy consulted at use-case entry |
When you practice, time how long the twist takes. Under five minutes with a clear narration is a strong signal. Fifteen minutes of redrawing usually means the first design hid the volatility inside concrete types.
What to say when you did not leave a seam
Be honest: “I hardcoded email sends inside OrderService, so this change forces an edit there. I would extract a Notifier interface now, migrate the email impl, then add SMS.” Interviewers respect a clean recovery more than a pretend-perfect first draft.
06OCP vs Long-Term Evolution
OCP drills are local: one change, minimal edits. Multi-stage product growth — new markets, debt, scale — needs a longer lens. Continue with evolving software design as requirements grow when you are ready for multi-stage thinking.
07Key Takeaways
- Requirement twists test OCP and calm under pressure.
- Identify volatility early; place interfaces there.
- Measure success by blast radius, not by pattern count.
- Extend with new types when the variation is behavioral.
Practice absorbing one surgical change at a time in Change One Thing.
Frequently Asked Questions
ABlast radius is how many types you must edit to satisfy a new requirement. Small blast radius usually means better OCP alignment.
LLDCanvas Team
Engineering at LLDCanvas
Ready to practice?
Turn reading into results
110+ LLD interview questions, a live canvas, and timed Interview Mode.
Reader’s Notes (0)
Sign in to join the discussion
Sign inLoading notes…