Bird
Raised Fist0

Which of the following is a common trade-off or limitation when strictly applying the Open/Closed Principle in a large software system?

medium🪤 Complexity Trap Q13 of Q15
OOP & Design Patterns - Open/Closed Principle - Open for Extension, Closed for Modification
Which of the following is a common trade-off or limitation when strictly applying the Open/Closed Principle in a large software system?
AIt forces all changes to be made in a single base class, increasing risk of bugs
BIt can lead to excessive class proliferation, making the codebase harder to navigate
CIt eliminates the need for interfaces or abstract classes, simplifying design
DIt guarantees zero runtime overhead due to polymorphism
Step-by-Step Solution
  1. Step 1: Identify trade-offs of OCP

    Strict adherence often results in many small subclasses, increasing complexity.
  2. Step 2: Why other options are false

    It forces all changes to be made in a single base class, increasing risk of bugs is opposite to OCP's goal; changes are made via extension, not base modification. It eliminates the need for interfaces or abstract classes, simplifying design is false because OCP relies on abstractions like interfaces. It guarantees zero runtime overhead due to polymorphism is incorrect; polymorphism can introduce slight runtime overhead.
  3. Final Answer:

    Option B -> Option B
  4. Quick Check:

    Class explosion is a known practical downside of OCP.
Quick Trick: OCP can cause many small classes [OK]
Common Mistakes:
MISTAKES
  • Thinking OCP centralizes changes in base classes
  • Believing OCP removes need for abstractions
  • Assuming polymorphism has no runtime cost
Trap Explanation:
PITFALL
  • Options B and C contradict OCP principles; D is a misconception about performance.
Interviewer Note:
CONTEXT
  • Tests candidate's awareness of practical trade-offs and limitations of OCP.
Master "Open/Closed Principle - Open for Extension, Closed for Modification" in OOP & Design Patterns

2 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More OOP & Design Patterns Quizzes