56 Design Patterns interview questions with answers
56 Design Patterns interview questions with detailed answers, sorted from basic to advanced. Free to practice, with progress saved automatically.
All Design Patterns interview questions
What is the Single Responsibility Principle (SRP) and why does it matter?
What is the Open/Closed Principle (OCP)? Give a real-world example.
What is the Liskov Substitution Principle (LSP)? When is it violated?
What is the Interface Segregation Principle (ISP)? Example in TypeScript?
What is the Dependency Inversion Principle (DIP)? How does it relate to Dependency Injection?
What are DRY, KISS, and YAGNI? When should — and shouldn't — you apply them?
Why does SOLID matter in real-world software development?
How do you apply SOLID principles in a real Next.js/React project?
What is the Singleton pattern? What problems does it cause in modern environments?
What is the Factory Method pattern? How does it differ from Simple Factory?
What is the Abstract Factory pattern? When should you use it instead of Factory Method?
What is the Builder pattern? What advantages does it have over constructors with many parameters?
What is the Prototype pattern? When should you use it in JavaScript/TypeScript?
What is the Object Pool pattern? Real-world use cases in Node.js and Go?
What is Dependency Injection (DI)? What are the types of DI and what frameworks support it?
When should you use Creational patterns? How do you choose the right one?
What is the Adapter pattern? Real-world example in TypeScript?
What is the Bridge pattern? How does it differ from Adapter?
What is the Composite pattern? When should you use it?
What is the Decorator pattern? How does it differ from Inheritance? TypeScript example?
What is the Facade pattern? How is it applied in frontend development?
What is the Proxy pattern? What are the common types of Proxy?
What is the Flyweight pattern? When should you use it?
When should you use Structural patterns? How do you choose the right one?
What is the Observer pattern? How is it applied in JavaScript/React?
What is the Strategy pattern? How does it compare to if/else and switch/case?
What is the Command pattern? How is Undo/Redo implemented with it?
What is the Template Method pattern? How does it differ from Strategy?
What is Chain of Responsibility? How is it applied in Express.js middleware?
What is the State pattern? How does it differ from a Finite State Machine (FSM)?
What is the Mediator pattern? How does it differ from Observer, and why does it matter in microservices?
What is the Iterator pattern? How does the JavaScript Iterator Protocol work?
What is the Visitor pattern? When is it the right choice?
What are MVC, MVP, and MVVM? Key differences and applications in modern frontend?
What are the most important anti-patterns to avoid in software development? Real-world examples?
What are the four pillars of object-oriented programming (OOP)?
What is the Memento pattern? How does it support undo/redo?
What is the Null Object pattern? How does it eliminate null checks?
How do Association, Aggregation, and Composition differ in object relationships (UML)?
What are cohesion and coupling? Why aim for high cohesion and low coupling?
My shipping-fee function is a long if/else over carrier type, and every new carrier means editing it again. How do I refactor?
My constructor takes 8 parameters, several optional, and call sites look like `null, null, true`. How should I fix it?
We initialize different storage/payment implementations based on environment config. When is Factory Method the right tool, and when Abstract Factory?
Why is Singleton often called an anti-pattern, especially in code that has unit tests?
When an order becomes paid I must send mail, reserve stock, write a log, and push a notification. `markPaid` keeps growing. What do I do?
I need to add caching, retry, and timing to a running service without editing its class. How?
We call a payment gateway SDK from all over the codebase, so switching providers later means editing everywhere. How should we wrap it?
My signup controller calls six services in sequence (create user, create profile, send mail, write audit...). Should I group them, and with what?
What problem does the Repository pattern solve, and when is it a useless extra layer?
How does Dependency Injection differ from Service Locator, and why is Service Locator usually rated lower?
Three import jobs (CSV, Excel, XML) share one processing skeleton but differ in parsing. Template Method or Strategy?
An editor feature needs undo/redo, and some operations must run in the background through a queue. How does Command help, and what should I watch out for?
Our order lifecycle (pending → paid → shipped → completed / cancelled / refunded) is enforced by scattered ifs. How do I model it as a state machine?
What does applying Dependency Inversion look like in a real project? Is extracting an interface enough?
How do you apply the Open/Closed Principle in practice without falling into premature abstraction?
How do you spot a codebase that over-uses design patterns, and how do you improve it incrementally instead of rewriting?