My Design Patterns Catalog
by Riley MacDonald, November 10, 2017
I’ve published several posts on design patterns I’ve studied. This is my personal catalog for all the design patterns I’ve written about organized into three categories: Creational, Behavioral and Structural.
Creational
Creational patterns cover object instantiation allowing a client to decouple the objects it needs to create.
- Singleton: The singleton pattern enforces object instantiation in order to guarantee only one instance of an Object can be created.
- Factory Method: The factory pattern decouples dependencies making it possible to construct objects without really knowing what the exact class is.
- Abstract Factory: The Abstract Factory pattern is generally used to create a family of dependent or related products while the Factory Pattern is used to create one type of Object. Both patterns consecrate object instantiation to subclasses.
Behavioral
Behavioral patterns cover how objects and classes manage responsible and interact.
- Template Method: The template pattern defines an algorithm in a superclass and makes subclasses responsible for some of the logic.
- Iterator: The iterator pattern simplifies interactions between various objects that use different types of Collections to store data.
- Command: The command pattern is most commonly used in scenarios where commands or requests are made.
- Observer: The Observer Pattern utilizes a one to many relationship to notify interested objects of changes. Observers register with a Subject to be notified of updates.
- State: The state pattern is very similar to the Strategy Pattern as it allows the behavior of objects to be altered at runtime. Objects behavior will be based on its internal state. The behavior of these states are broken down into separate classes.
- Strategy: The strategy pattern is used to encapsulate functionality and maximize maintainability while exercising polymorphism and inheritance.
Structural
Structural patterns cover composing objects or classes into larger structures.
- Proxy: The proxy pattern uses a representative object that controls access to another object.
- Decorator: The decorator pattern also allows additional responsibilities to be added to an object dynamically at runtime as opposed to statically during compile time.
- Composite: The composite design pattern is used to “compose” objects into tree structure type hierarchies.
- Facade: The Facade Design Pattern is implemented by defining a single interface that interacts with several interfaces within a system.
- Adapter: The Facade Pattern simplifies interactions with various interfaces while the Adapter Pattern makes a connection between classes that otherwise couldn’t due to incompatible interfaces.