C++ Design Patterns
Design patterns are reusable solutions to common software design problems. They are grouped into three categories: Creational, Structural, and Behavioral.
Creational Patterns
Singleton
Ensure a class has only one instance and provide global access.
Factory Method
Create objects without specifying their exact class.
Abstract Factory
Produce families of related objects without specifying concrete classes.
Builder
Construct complex objects step by step.
Prototype
Create new objects by copying existing ones.
Structural Patterns
Adapter
Allow incompatible interfaces to work together.
Bridge
Separate abstraction from implementation.
Composite
Treat individual objects and groups uniformly.
Decorator
Add responsibilities dynamically to objects.
Facade
Provide a simplified interface to complex systems.
Proxy
Provide a surrogate or placeholder for another object.
Flyweight
Reduce memory usage by sharing common object data across many objects.
Behavioral Patterns
Observer
Notify multiple objects when state changes.
Strategy
Define interchangeable algorithms.
Command
Encapsulate a request as an object.
State
Allow an object to change behavior when its state changes.
Iterator
Access collection elements sequentially without exposing structure.
Mediator
Reduce dependencies between objects by introducing a mediator.
Memento
Capture and restore an object's internal state without exposing its structure.
Chain of Responsibility
Pass a request along a chain of handlers until one processes it.
Template Method
Define the skeleton of an algorithm while allowing subclasses to override steps.
Visitor
Add new operations to object structures without modifying the classes.