Design patterns in images

Intention:

Purpose of the article is to describe and remember GOF patterns in a quick way by having a short description and diagram.

This page do not provide entire description and selection principles or use cases for each patern, for more details please refer to the following books:

  1. Head First Design Patterns  by Eric Freeman, Elisabeth Robson, Bert Bates, Kathy Sierra.
  2. Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides, Grady Booch.

Description:

Christopher Alexander says:
"Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice" [1]

Pasterns are split in 3 main groups:

GroupPatternDescription
StructuralAdapterAllows the interface of an existing class to be used from another interface.
BridgeAllows decoupling abstraction from implementation so that the two can vary independently.
CompositeResponsible to compose objects structure into tree and enable to treat them in the same way as a single object.
DecoratorAllows behaviour to be added to an individual object without affecting the behaviour of other objects from the same class.
FacadeProvides a simplified interface to a larger body of code or subsystem.
FlyweightAllows to minimize memory used by sharing as much data as possible with other similar objects storage costs of objects.
ProxyA wrapper or agent object that is being called by the client to access the real serving object behind the scenes.
CreationalAbstract FactoryProvides a way to encapsulate a group of individual families without specifying their concrete classes.
BuilderCreate composite object and describes the way how the object gets created.
Factory MethodCreating objects without having to specify the exact class of the object that will be created.
PrototypeDescribes type of objects to be created which is determined by a prototypical instance.
SingletonRestricted creation of instances and promote sole instance per system.
BehavioralChain of ResponsibilityEach processing object contains algorithms that defines the types of command objects that it handles.
CommandAn object is used to encapsulate all information needed to perform an action or trigger an event at a later time.
InterpreterSpecifies how to evaluate grammar and interpretation of a language.
IteratorUsed to describe the way how to traverse a container and access the container of the elements.
MediatorDefines an object that encapsulates how and which objects interact with each other.
MementoProvides the ability to restore an object to its previous state.
ObserverSubject maintains a list of its dependencies, and notifies them automatically of any state changes.
StateEncapsulate different behaviour for the same object based on its internal state.
StrategyEnables an algorithm's behaviour to be selected at a runtime.
Template MethodDefines the program skeleton of an algorithm in a method.
VisitorAllows separate an algorithm from an object structure on which it operates.



Structural Patterns:

Structural patterns is responsible for composition of objects might be named as well entities builder, those pasterns is dealing with data structures.



Adapter

Example of Adapter pattern available on github: https://github.com/ecararus/adapter

Bridge

Example of Bridge pattern available on github: https://github.com/ecararus/bridge

Composite

Example of Composite pattern available on github: https://github.com/ecararus/composite

Decorator

Example of Decorator pattern available on github: https://github.com/ecararus/decorator

Facade

Example of Facade pattern available on github: https://github.com/ecararus/facade

Flyweight

Example of Flyweight pattern available on github: https://github.com/ecararus/flyweight

Proxy
Example of Proxy pattern available on github: https://github.com/ecararus/proxy



Creational patterns:

Creational patterns responsible for ways of object creation.



Abstract Factory
  •                              

Builder

Factory Method

Prototype

Singleton

Behavioral Patterns:

Behavioral patterns responsible for ways in which classes or objects interact and separation of concerns.


Chain of Responsibility

Command

Interpreter

Iterator

Mediator

Memento

Observer

State

Strategy

Template Method

Visitor


Conclusion:
The scope of design patterns is to provide an optimal designed solution for a specific range of problem, as well pattens should serves as referral for every software developer and help in communication with others.

[1] Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides, Grady Booch - p12.

No comments:

Post a Comment