Phase 6 of 9 · 10 lessons
Design patterns
Ten patterns that come up again and again in LLD interviews and real code: three for creating objects, three for structuring them, and four for behaviour.
A pattern is a proven shape for a common problem, with a name everyone recognises. In an interview, naming the right pattern — and saying why it fits — shows you design for change, not just for today.
Lessons, in order
-
6.1
Singleton
Makes sure a class has only one instance, and gives one global way to reach it.
-
6.2
Factory: Factory Method and Abstract Factory
A factory creates objects for you, so the calling code asks for 'a notifier' without knowing which concrete class gets built.
-
6.3
Builder
Builds a complex object step by step, instead of using a constructor with a dozen parameters.
-
6.4
Adapter
Lets two incompatible interfaces work together, by wrapping one so it looks like the other.
-
6.5
Decorator
Adds behaviour to an object by wrapping it in another object with the same interface, without changing the original class.
-
6.6
Facade
Gives one simple interface to a complicated set of classes.
-
6.7
Strategy
Puts a family of interchangeable algorithms behind one interface, so you can choose one at runtime.
-
6.8
Observer
Lets objects subscribe to another object's events, and get notified automatically when something happens.
-
6.9
Chain of Responsibility
Passes a request along a chain of handlers; each one either deals with it or passes it on to the next.
-
6.10
State
Lets an object change its behaviour when its internal state changes, by putting each state's behaviour in its own class.