Is it possible to over-apply the Open/Closed Principle, and what does that look like?
Yes — designing every class to be maximally extensible from the very first line of code is a real and common mistake, sometimes called speculative generality. It shows up as interfaces created for a single implementation that will likely never gain a second one, abstraction layers built around extension points nobody has actually asked for, and constructors accepting strategy objects that are always passed the exact same value in practice. The cost is real: extra indirection makes the code harder to read and navigate for no actual flexibility gained, since the theoretical future case never materializes. OCP earns its value specifically at points in the code that demonstrably change often — a known, recurring source of new cases, like payment methods in a growing fintech product — not as a blanket policy applied everywhere in advance.
Ready to master this question?
Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.
Sign in to generate a response