Design Patterns
Design Patterns
All 23 Gang of Four patterns โ Creational, Structural, and Behavioral โ with multi-class UML diagrams, full Java implementations, anti-patterns, and interview preparation guides.
23 patterns 3 categories 4 reference guides Java + Python implementations
01
Category One ยท Object Creation
Creational Patterns
Singleton
- Ensure a class has only one instance
- Tier 1 ยท Foundational
Factory Method
- Defer instantiation to subclasses
- Tier 1 ยท Foundational
Abstract Factory
- Create families of related objects
- Tier 2 ยท Intermediate
Builder
- Construct complex objects step by step
- Tier 2 ยท Intermediate
Prototype
- Clone existing objects without coupling
- Tier 3 ยท Intermediate
02
Category Two ยท Object Composition
Structural Patterns
Adapter
- Convert one interface to another
- Tier 2 ยท Foundational
Bridge
- Separate abstraction from implementation
- Tier 3 ยท Intermediate
Composite
- Compose objects into tree structures
- Tier 2 ยท Intermediate
Decorator
- Add responsibilities dynamically
- Tier 1 ยท Intermediate
Facade
- Provide a simplified interface
- Tier 2 ยท Foundational
Flyweight
- Share fine-grained objects efficiently
- Tier 3 ยท Advanced
Proxy
- Control access to another object
- Tier 2 ยท Intermediate
03
Category Three ยท Communication
Behavioral Patterns
Observer
- Notify dependents of state changes
- Tier 1 ยท Foundational
Strategy
- Encapsulate interchangeable algorithms
- Tier 1 ยท Foundational
Command
- Encapsulate a request as an object
- Tier 2 ยท Intermediate
Template Method
- Define algorithm skeleton, defer steps
- Tier 2 ยท Foundational
Chain of Responsibility
- Pass request along a chain of handlers
- Tier 3 ยท Intermediate
State
- Alter behavior when internal state changes
- Tier 2 ยท Intermediate
Mediator
- Centralize complex communications
- Tier 3 ยท Intermediate
Iterator
- Access elements sequentially
- Tier 2 ยท Foundational
Visitor
- Add operations without changing classes
- Tier 3 ยท Advanced
Memento
- Capture and restore object state
- Tier 3 ยท Intermediate
Interpreter
- Define a grammar and interpret sentences
- Tier 3 ยท Advanced
04
Category Four ยท Reference Guides
Reference & Guides
Interview Patterns
- Tier 1โ3 pattern ranking
- What interviewers test
Anti-Patterns
- The wrong approach for each pattern
- How to recognise and fix them
Pattern Relationships
- Confused-with pairs
- Compose-together trios
Java Stdlib Map
- Every pattern in the JDK
- Real class and method references