Design Patterns
Classic and modern design patterns for writing clean, maintainable, and extensible code across any programming language.
Filter by tag:
Creational Patterns
Factory Method
Define an interface for creating objects, letting subclasses decide which class to instantiate — decouples object creation from usage.
Builder
Construct complex objects step by step — separates construction from representation, ideal for objects with many optional parameters.
Singleton
Ensure a class has only one instance and provide a global access point — use sparingly, often considered an anti-pattern.
Structural Patterns
Adapter
Convert the interface of a class into another interface clients expect — enables classes with incompatible interfaces to work together.
Decorator
Attach additional responsibilities to objects dynamically — a flexible alternative to subclassing for extending functionality.
Facade
Provide a simplified interface to a complex subsystem — reduces coupling between clients and internal components.
Behavioral Patterns
Observer
Define a one-to-many dependency so that when one object changes state, all dependents are notified — the foundation of reactive programming.
Strategy
Define a family of algorithms, encapsulate each one, and make them interchangeable — lets the algorithm vary independently from clients.
Repository Pattern
Mediates between the domain and data mapping layers — provides a collection-like interface for accessing domain objects.
References
Refactoring Guru — All Patterns
Comprehensive catalogue of all 22 Gang of Four design patterns with examples in multiple languages, UML diagrams, and real-world analogies.
Patterns of Enterprise Application Architecture
Martin Fowler's classic reference covering enterprise patterns — Unit of Work, Data Mapper, Active Record, and many more.