Design Patterns


Name Description
Chain of Responsibility

A way of passing a request between a chain of objects. Works with a list of Handler objects that have limitations on the nature of the requests they can deal with. If an object cannot handle

Command

Encapsulate a command request as an object. Creates distance between the client that requests an operation and the object that can perform it. It can support: sending requests to different receivers, queuing, logging, and rejecting requests, redo and undo functionality

Interpreter

A way to include language elements in a program. Supports the interpretation of instructions written in a language or notation defined for a specific purpose.

Iterator

Sequentially access the elements of a collection. Provides a way of accessing elements of a collection sequensequentially, without knowing how the collection is structured.

Mediator

Enable objects to communicate without knowing each other’s identities. It also encapsulates a protocol that objects can follow.

Memento

Capture and restore an object's internal state. Used to capture an object’s internal state and save it externally so that it can be restored later.

Observer

A way of notifying change to a number of classes. Defines a relationship between objects so that when one changes its state, all the others are notified accordingly. There is usually an identifiable single publisher of new state, and many subscribers who wish to receive it.

State

Alter an object's behavior when its state changes. A dynamic version of the Strategy pattern. When the state inside an object changes, it can change its behavior by switching to a set of different operations.

Strategy

Encapsulate an algorithm inside a class. Involves removing an algorithm from its host class and putting it in a separate class. There may be different algorithms (strategies) that are applicable for a given problem.

Template Method

Defer the exact steps of an algorithm to a subclass. Enables algorithms to defer certain steps to subclasses.

Visitor

Defines a new operation to a class without change. Defines and performs new operations on all the elements of an existing structure, without altering its classes.

Name Description
Abstract Factory

Supports the creation of products that exist in families and are designed to be produced together. The abstract factory can be refined to concrete factories, each of which can create different products of different types.

Builder

Separates the specification of a complex object from its actual construction. The same construction process can create different representations.

Factory Method

Creates an instance of several derived classes. The Factory Method pattern is a way of creating objects, but letting subclasses decide exactly which class to instantiate. Various subclasses might implement the interface; the Factory Method instantiates the appropriate subclass based on information supplied by the client or extracted from the current state.

Prototype

A fully initialized instance to be copied or cloned. Creates new objects by cloning one of a few stored prototypes. The Prototype pattern has two advantages: it speeds up the instantiation of very large, dynamically loaded classes (when copying objects is faster), and it keeps a record of identifiable parts of a large data structure that can be copied without knowing the subclass from which they were created

Singleton

A class in which only a single instance can exist. Ensure that there is only one instance of a class, and that there is a global access point to that object.

Name Description
Adapter

Match interfaces of different classes. Enables a system to use classes whose interfaces don’t quite match its requirements. It is especially useful for off-the-shelf code, for toolkits, and for libraries.

Bridge

Decouples (separates) an abstraction from its implementation, enabling them to vary independently. The Bridge pattern is useful when a new version of software is brought out that will replace an existing version, but the older version must still run for its existing client base. The client code will not have to change, as it is conforming to a given abstraction, but the client will need to indicate which version it wants to use.

Composite

A tree structure of simple and composite objects. Arranges structured hierarchies so that single components and groups of components can be treated in the same way. Typical operations on the components include add, remove, display, find, and group.

Decorator

Provides a way of attaching new state and behavior to an object dynamically.

Façade

Provides different high-level views of subsystems whose details are hidden from users.

Flyweight

Promotes an efficient way to share common information present in small objects that occur in a system in large numbers. It thus helps reduce storage requirements when many values are duplicated.

Proxy

The Proxy pattern supports objects that control the creation of and access to other objects. The proxy is often a small (public) object that stands in for a more complex (private) object that is activated once certain circumstances are clear.

Name Description