Learning roadmap
Learn each topic from scratch, then practice the interview questions on it — in order.
1
1. Learn
OOP Recap & UMLSingle Responsibility PrincipleOpen/Closed PrincipleLiskov Substitution PrincipleInterface Segregation PrincipleDependency Inversion PrincipleMemento PatternObserver PatternStrategy PatternCommand PatternTemplate Method PatternIterator PatternState PatternMediator PatternSingleton PatternFactory Method PatternAbstract Factory PatternBuilder PatternPrototype PatternAdapter PatternDecorator PatternProxy PatternComposite PatternFacade PatternFlyweight PatternBridge, Visitor & Chain of ResponsibilityCapstone: Ride-Sharing App
2. Practice interview questions
How is the Strategy pattern specifically a form of the Open/Closed Principle?Why does the classic 'Square extends Rectangle' design violate the Liskov Substitution Principle?What does Abstract Factory guarantee that using several independent Factory objects cannot?What is the difference between intrinsic and extrinsic state in the Flyweight pattern, and why does that distinction matter for memory usage?In the Command pattern, what's the difference between the Invoker and the Receiver, and why does that split matter?How does a virtual proxy implement lazy loading, and what determines when the real object actually gets created?What specific problem does the Factory pattern solve that plain object construction does not?Why is the orchestrating method in a Template Method typically declared final, and what breaks if it isn't?What is a common code smell that signals an interface is violating the Interface Segregation Principle?What are the essential building blocks of a Singleton implementation in Java, and why does each one matter?Why does exposing a collection's raw backing structure to client code create a real maintenance risk?What's the difference between what the Facade pattern and the Adapter pattern are each trying to solve?What problem does introducing a mediator object actually solve in a system where many objects need to communicate?How does the State pattern differ from simply using an enum with a switch statement to control behavior?Why does the Decorator pattern scale better than subclassing when you have several optional, independently combinable features?What's the difference between Dependency Inversion and Dependency Injection?What does it mean for a class to be 'open for extension but closed for modification'?When should you actually reach for the Adapter pattern instead of just modifying one of the two mismatched classes directly?In the Memento pattern, why shouldn't the Caretaker be able to read the contents of a Memento it's holding?How do you identify whether a class violates the Single Responsibility Principle?What is the difference between compile-time polymorphism (method overloading) and runtime polymorphism (method overriding) in Java?What is the difference between a shallow copy and a deep copy, and why does it matter when writing a clone() method?Why does hardwiring a Subject class directly to a concrete Observer type create an Open/Closed Principle violation?What signal tells you a design problem is a genuine fit for the Composite pattern?Why does a single constructor with many parameters, some of them optional, become a real risk rather than just an inconvenience?How does Abstract Factory make it structurally impossible to end up with a mismatched pair of related objects?When designing two related classes, how do you decide whether to use inheritance or composition?Does the Single Responsibility Principle mean a class should only ever have one method?How would you refactor a large if/else or switch statement that branches on a type string to follow the Open/Closed Principle?What is the difference between structural compatibility and behavioral compatibility when substituting a subclass for its parent?How is the Interface Segregation Principle different from the Single Responsibility Principle?Why does depending on concrete classes instead of interfaces make unit testing harder?How would you extend a Memento-based undo implementation to also support redo?How can the Observer pattern cause a memory leak, and how would you prevent it?Strategy and State look structurally almost identical. What's the actual difference between them?How is the Adapter pattern different from the Facade pattern, given that both wrap other classes?The basic Command interface only has an execute() method. What has to change to support undo?What's the difference between an abstract method and a hook method in the Template Method pattern?Why does an iterator's current position live on the iterator object itself, rather than on the collection being traversed?What is a self-transitioning state, and how is it different from the simpler, caller-driven use of the State pattern?Does the Mediator pattern eliminate coupling between objects, or does it just move it somewhere else?Why does the simple, lazily-initialized Singleton break under concurrency, and how does double-checked locking fix it?Why should a factory method throw an exception for an unrecognized type instead of returning null?Why is a builder for a class commonly implemented as a static nested class rather than a separate top-level class?Why might a team choose a hand-written Prototype interface over Java's built-in Cloneable and Object.clone()?Decorator and Proxy have nearly identical class structures. How do you tell which pattern you're actually looking at?What thread-safety bug can a naive lazy-loading proxy have, and how would you fix it?What bug can occur in a Composite tree structure if you don't guard against it, and how would you prevent it?How can a Facade class turn into a god object over time, and what's the usual way to prevent that?When is the Flyweight pattern actually worth applying, and what makes it risky to reach for by default?Can you give a concrete example of the Strategy pattern already built into the Java standard library?What is the real cost of adding a new product to an existing Abstract Factory family, compared to adding a new family such as a new theme?Java's standard library included java.util.Observer and java.util.Observable since version 1.0 — why were they deprecated?How does a typical Spring Boot @Service class often act as a Facade, even without anyone naming it that way?What is the difference between an abstract class and an interface in Java, and when would you choose one over the other?Why must a shared flyweight object be immutable once it has been constructed?When is it safe to share a single instance of a state class across multiple context objects, and when does that become a bug?What actually happens under the hood when you write a for-each loop over a Java collection?In a chat-room mediator, why does the mediator need to distinguish between a user sending and other users receiving a message?Most behavioral patterns favor composition over inheritance. Why does Template Method deliberately do the opposite?What is the core criticism of the Singleton pattern, and what would a better alternative look like in a Spring application?How does java.lang.Runnable relate to the Command pattern?When is introducing a Factory pattern unnecessary, and what is the risk of overusing it?How does the Builder pattern differ from the Factory pattern, given that both are considered creational patterns?What's a genuine practical cost of using the Memento pattern that you should be ready to discuss in an interview?When does cloning an existing object actually give a real performance advantage over just constructing a new one?How does the Dependency Inversion Principle relate to how Spring's @Autowired dependency injection works?In Java, why is object composition typically used to build an adapter instead of inheriting from the class being adapted?Can you over-apply the Interface Segregation Principle? What's the downside of splitting interfaces too finely?Can the order in which decorators are stacked change the final behavior of the wrapped object, and if so, how?What is a real example from the Java standard library where a class technically satisfies an interface but violates LSP?How do ORM frameworks like Hibernate use the Proxy pattern for lazy loading of related entities?Is it possible to over-apply the Open/Closed Principle, and what does that look like?How should you handle an operation, like adding a child, that only makes sense on composite nodes and not on leaves?How does the Single Responsibility Principle relate to the layered architecture used in a typical Spring Boot application?How do you tell the Bridge pattern apart from the Strategy pattern when both involve a class holding a reference to an interface it delegates to?How does the Bridge pattern prevent the class explosion that happens when you model every combination of two independent hierarchies as its own class?What does double dispatch mean in the Visitor pattern, and how does it let a program run different logic per concrete type without any instanceof checks?What trade-off does the Visitor pattern make, and when does that trade-off actually work in your favor?In the Chain of Responsibility pattern, does the object sending a request need to know in advance which handler will actually process it?Why does the order in which handlers are linked together in a Chain of Responsibility matter more than layering order typically does when stacking purely additive behavior?In a ride-sharing service where fare calculation branches on a raw vehicle type string, which principle is being violated and which pattern fixes it?In a ride-sharing system's design, why should fare strategy (standard, shared, luxury) and vehicle type (car, bike) be modeled as two separate hierarchies instead of one combined hierarchy?How can a ride-sharing app's ride-status notifications be an example of the Observer pattern even if the code has no class explicitly named Observer or Subject?Why is a dedicated matching service that coordinates drivers and passengers described as a Mediator, and what would be lost if Driver and Passenger referenced each other directly instead?
2
3