mySystemDesign Logo

mySystemDesign
BEGINNER TO ADVANCED

PROGRESS
0%

Design Patterns

Gang of Four (GoF) patterns, categorised by use cases.
#PatternCategoryImportanceStatusOne-line IdeaBest Resources
1
OOP — 4 Pillars
Fundamentalscritical
Encapsulation, Abstraction, Inheritance, Polymorphism. Foundation of every LLD interview.
2
SOLID Principles
Fundamentalscritical
SRP, OCP, LSP, ISP, DIP. 5 rules for clean, maintainable, extensible OOP code.
3
Composition over Inheritance
Fundamentalshigh
Prefer has-a over is-a. More flexible. Avoids brittle deep class hierarchies.
4
UML Class Diagrams
Fundamentalshigh
Draw classes, interfaces, and relationships before writing a single line of code.
5
Interfaces vs Abstract Classes
Fundamentalscritical
Interface = contract, supports multiple. Abstract = partial implementation. Know when to use each.
6
Concurrency & Thread Safety
Fundamentalshigh
Race conditions, deadlocks, mutex, semaphore, ReentrantLock, ThreadLocal, immutability.
7
Singleton
Creationalcritical
One global instance. Thread-safe via enum or double-checked locking. Logger, Config, DB Pool.
8
Factory Method
Creationalcritical
Let subclasses decide which object to create. Decouples instantiation from usage. Open/Closed.
9
Abstract Factory
Creationalhigh
Factory of factories. Create families of related objects. Cross-platform UI toolkit example.
10
Builder
Creationalcritical
Construct complex objects step by step. Fluent API. Avoids telescoping constructor anti-pattern.
11
Prototype
Creationalmedium
Clone existing objects instead of constructing from scratch. Shallow vs deep copy.
12
Object Pool
Creationalmedium
Reuse a fixed set of pre-created objects. Avoids expensive construction. DB connections, threads.
13
Adapter
Structuralcritical
Convert an incompatible interface into the expected one. Wrap legacy or third-party classes.
14
Decorator
Structuralcritical
Add responsibilities to objects dynamically. Wrap in decorator objects. Java I/O streams.
15
Facade
Structuralcritical
Provide a simple interface to a complex subsystem. Hide internal complexity from clients.
16
Proxy
Structuralhigh
Surrogate for another object. Lazy init, access control, logging, caching proxy.
17
Composite
Structuralhigh
Treat individual and composed objects uniformly. Tree structures. File system, UI component trees.
18
Bridge
Structuralmedium
Decouple abstraction from implementation. Both can vary independently. Cross-platform rendering.
19
Flyweight
Structuralmedium
Share fine-grained objects to save memory. Intrinsic (shared) vs extrinsic (per-use) state.
20
Observer
Behaviouralcritical
Subject notifies subscribed observers when state changes. Foundation of event systems.
21
Strategy
Behaviouralcritical
Define a family of algorithms, encapsulate each, make them interchangeable at runtime.
22
State
Behaviouralcritical
Allow object to change behaviour when internal state changes. Finite State Machine in OOP.
23
Command
Behaviouralhigh
Encapsulate a request as an object. Enables undo/redo, queuing, logging. Text editor actions.
24
Template Method
Behaviouralhigh
Define skeleton of algorithm in base class, let subclasses fill in the steps. Hollywood Principle.
25
Iterator
Behaviouralhigh
Sequentially access elements of a collection without exposing its structure. Java Iterator.
26
Chain of Responsibility
Behaviouralhigh
Pass request along a chain of handlers. Each decides to process or pass on. Middleware, logging.
27
Mediator
Behaviouralmedium
Centralise communication between objects. Reduces many-to-many coupling. Chat room example.
28
Memento
Behaviouralmedium
Capture and restore object state without exposing internals. Undo functionality.
29
Visitor
Behaviouralmedium
Add new operations to object structures without modifying them. Double dispatch.
30
Interpreter
Behaviourallow
Define a grammar for a language, provide an interpreter to deal with it. SQL, regex parsing.