InterviewStack.io LogoInterviewStack.io

Object Oriented Design Principles Questions

Technical principles for designing object oriented systems that are maintainable, extensible, and testable. Topics include single responsibility, open closed, Liskov substitution, interface segregation, and dependency inversion principles; composition versus inheritance trade offs; designing clear and minimal public interfaces and application programming interfaces; separation of concerns, low coupling and high cohesion; use of design patterns where appropriate; strategies for dependency management and dependency injection; and practices that improve testability such as designing for mocking and modularity. Interviewers evaluate ability to reason about class and module boundaries, extensibility, performance and complexity trade offs, and to produce clean code and APIs that support long term maintenance.

MediumTechnical
0 practiced
Implement the Strategy pattern in Python to allow swapping discount calculation strategies for a shopping cart at runtime. Provide class definitions for a Cart, a DiscountStrategy interface, two strategies (PercentageDiscount, ThresholdDiscount), and show how a new strategy can be registered and used by clients. Focus on testability.
MediumTechnical
0 practiced
You inherit a large 'PaymentProcessor' class that performs validation, payment gateway calls, logging, and metrics collection. It is brittle and hard to extend. Describe step-by-step how you would refactor it to apply SRP, DIP, and improve testability, without changing external behavior. Provide the responsibilities of extracted classes and interfaces.
MediumTechnical
0 practiced
Explain constructor injection, setter injection, and interface injection as dependency injection techniques. For each approach, state pros and cons, when to prefer it, and show a compact Java snippet illustrating constructor injection for a service depending on a repository interface.
MediumTechnical
0 practiced
Describe how to implement the Repository pattern in a layered architecture. Include repository interfaces, DTOs versus domain entities, transaction boundaries, and considerations for testing and mocking repositories. Provide a sample interface and explain typical implementations for relational and NoSQL backends.
MediumTechnical
0 practiced
Discuss the trade-offs of making classes final/sealed versus intentionally allowing subclassing in public APIs. How does sealing types affect testing (mocking), extensibility, binary compatibility, and future maintenance? Give scenarios where sealing is the safer choice and where open extension is necessary.

Unlock Full Question Bank

Get access to hundreds of Object Oriented Design Principles interview questions and detailed answers.

Sign in to Continue

Join thousands of developers preparing for their dream job.