OOP Design Patterns are development templates that give software designers and coders shorthand ways of thinking about and solving programming challenges.
A full explanation of OOP Design Patterns can (and does) fill entire textbooks. Understanding and remembering every aspect of every pattern can be a daunting task. Hopefully the brief descriptions below will help in remembering the function of some common Design Patterns.
Often programmers need to discuss pattern usage with software designers, managers and other programmers. Getting too lost in the details can distract from communicating the essence of a software solution. Design Patterns can help with these challenges.
Some commonly used Design Patterns are listed below. Click on the Design Pattern name for a full pattern description.
- Adapter - Facilitates object interaction.
- Bridge - Similar to the Adapter pattern but more robust.
- Builder - Similar to the Factory pattern for returning objects as an output but used in cases where many variables of output object construction are needed.
- Chain of Responsibility - Uses a sequence of processing code blocks, each of which handles a specific set of conditions before passing control to the next block.
- Command - Used to store and use the information needed to call a method at a later time.
- Composite - Describes that a group of objects is to be treated in the same way as a single instance of an object.
- Decorator - Also known as a wrapper, allows behavior to be added to an individual object.
- Facade - Provides a simplified interface to a larger body of code.
- Factory - Creates objects as a return output.
- Flyweight - Minimizes memory use by sharing as much data as possible with other objects.
- Interpreter - Specifies how to evaluate sentences in a language.
- Iterator - Used to traverse a container and access the container's elements.
- Mediator - Defines an object the encapsulates how a set of objects interact. Instead of communicating directly, the encapsulated objects communicate through the Mediator.
- Memento - Provides the ability to restore an object to its previous state, such as an undo via a rollback.
- Null Object - Object with defined neutral ("null") behavior.
- Object Pool - Set of initialized objects kept ready to use, rather than allocating and destroying them on demand. Thread Pools are a common Object Pool implementation.
- Observer - Maintains a list of other objects and notifies them of any state change. Objects that perform Callbacks operate as an observer.
- Prototype - Similar to the Factory pattern, creates objects based on prototypical instances.
- Proxy - Functions as an interface to something else.
- Singleton - Restricts the instantiation of a class to one object.
- Strategy - Enables an algorithm's behavior to be selected at runtime.
- Template - Defines the program skeleton of an algorithm and defers some steps to subclasses.
- Visitor - Separates an algorithm from the objects on which it operates.