Creational Patterns
Deal with object creation mechanisms, abstracting the instantiation process to make systems independent of how objects are created, composed, and represented.
Design patterns are proven, reusable solutions to common problems that arise in software design. First cataloged by the “Gang of Four” (Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides) in their landmark 1994 book Design Patterns: Elements of Reusable Object-Oriented Software, these patterns remain foundational knowledge for every software engineer.
Design patterns provide a shared vocabulary for developers. Instead of explaining a complex design decision from scratch, you can say “we used a Strategy pattern here” and your team immediately understands the architecture. They also:
Design patterns are organized into three categories based on their purpose:
Creational Patterns
Deal with object creation mechanisms, abstracting the instantiation process to make systems independent of how objects are created, composed, and represented.
Structural Patterns
Behavioral Patterns
Focus on communication between objects, defining how objects interact and distribute responsibility among themselves.
| Pattern | Intent | Common Use Cases |
|---|---|---|
| Singleton | Ensure a class has only one instance | Configuration managers, logging, connection pools |
| Factory Method | Define an interface for creating objects, letting subclasses decide which class to instantiate | UI component libraries, plugin systems, document parsers |
| Abstract Factory | Create families of related objects without specifying concrete classes | Cross-platform UI toolkits, database access layers |
| Builder | Construct complex objects step by step | Query builders, configuration objects, HTTP requests |
| Prototype | Create new objects by copying existing ones | Game entities, document templates, cached objects |
| Pattern | Intent | Common Use Cases |
|---|---|---|
| Adapter | Convert an interface into another that clients expect | Legacy system integration, third-party library wrappers |
| Bridge | Separate abstraction from implementation so both can vary | Cross-platform rendering, device drivers, persistence layers |
| Composite | Compose objects into tree structures for part-whole hierarchies | File systems, UI component trees, organizational charts |
| Decorator | Attach additional responsibilities to objects dynamically | I/O streams, middleware pipelines, logging wrappers |
| Facade | Provide a simplified interface to a complex subsystem | API gateways, library wrappers, service orchestration |
| Proxy | Provide a surrogate or placeholder to control access | Lazy loading, access control, caching, remote objects |
| Pattern | Intent | Common Use Cases |
|---|---|---|
| Observer | Define a one-to-many dependency so dependents are notified of changes | Event systems, reactive UI, pub/sub messaging |
| Strategy | Define a family of interchangeable algorithms | Sorting algorithms, payment processing, validation rules |
| Command | Encapsulate a request as an object | Undo/redo systems, task queues, macro recording |
| State | Allow an object to alter its behavior when its internal state changes | Workflow engines, TCP connections, game character AI |
| Iterator | Provide a way to access elements of a collection sequentially | Collection traversal, database cursors, stream processing |
| Template Method | Define the skeleton of an algorithm, deferring steps to subclasses | Frameworks, data pipelines, test fixtures |
Patterns often complement each other. Understanding these relationships helps you choose the right combination:
Creational Relationships: Abstract Factory ──uses──► Factory Method Builder ──can build──► Composite Prototype ──alternative to──► Factory Method
Structural Relationships: Adapter ──similar to──► Bridge (but different intent) Composite ──often uses──► Iterator Decorator ──similar to──► Proxy (but different intent) Facade ──simplifies──► Complex subsystems
Behavioral Relationships: Strategy ──similar to──► State (but different intent) Observer ──often uses──► Mediator Command ──can use──► Memento (for undo) Iterator ──traverses──► Composite Template Method ──alternative to──► Strategy (inheritance vs composition)Phase 1: Essential Patterns
Duration: 1-2 weeks
Start with the most commonly used patterns that you will encounter in everyday development.
Start with: Singleton, Factory Method, Observer, Strategy, Decorator
Prerequisites: Basic OOP knowledge (classes, interfaces, inheritance)
Phase 2: Structural Mastery
Duration: 1-2 weeks
Learn how to compose objects into flexible, maintainable structures.
Focus on: Adapter, Facade, Composite, Proxy, Builder
Prerequisites: Phase 1 patterns
Phase 3: Advanced Patterns
Duration: 2-3 weeks
Master the remaining behavioral patterns and learn to combine patterns effectively.
Focus on: Command, State, Template Method, Iterator, Abstract Factory, Bridge, Prototype
Prerequisites: Phases 1 and 2