How would you answer an interview scenario involving Open Closed Principle?
For an interview scenario involving Open Closed Principle, I would first clarify the business goal, scale, constraints, and the failure or quality attribute the interviewer wants to explore. OCP encourages designs that allow new behavior to be added with minimal modification to stable existing code. In this scenario, a tax calculator needs country-specific rules added regularly. Explain an OCP-friendly design. For production, use polymorphism, strategies, configuration, or composition around known variation points, not everywhere. I would then explain the main alternatives and tradeoffs, identify likely failure modes, and describe how I would validate the solution through testing, observability, security controls, and recovery or rollback planning.