Design Patterns - Summary
Tags: architecture, design, pattern, d3
Published: 2020-12-05 11:25:22

## Context
Since I begin my exercises of **Design Pattern** in Python, I saw a surge of reactions to this subject. Then I decide to make this work a little more systematic. It begins with this post which consists of a brief introduction of **Design Pattern** and a series of links of all my posts about Design Pattern exercises in Python. Thus this post will be updated at times in future with more and more examples.


## Concept of Design Pattern
Concept of **Design Pattern** in Software development has been systematically presented for the first time in book "Design Patterns - Elements of Reusable Object-Oriented Software" published in 1994. Four authors of this book, Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides are known nowadays as **Gang of Four** (**GOF**). They presented in this book 23 design patterns which are classified in three categories: **Creational**, **Structural** and **Behavioral patterns**.

Below is a graph I coded in d3 yesterday demonstrating classification of these patterns in **GOF**'s book: 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bgi7q6dzq5d5s0dpna35.png)

If someone is interested in an animation of this graph, refer to these pages: [web version](https://youtu.be/CeBsYxENOtI) and [app version](https://youtu.be/EIVqoLJK2Q4)

### Creational Patterns
**Creational Patterns** provide a way to create objects while hiding the creation logic, rather than instantiating objects directly using new operator. This gives program more flexibility in deciding which objects need to be created for a given use case.
Patterns included in this category are:
* Singleton Pattern [(example)](https://dev.to/jemaloq/design-pattern-in-python-singleton-5apj)
* Factory Pattern
* Abstract Factory
* Builder Pattern
* Prototype Pattern

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/dbfyfslytk9mpcxgw6vg.jpg)  

### Structural Patterns
Structural Patterns concern class and object composition. Concept of inheritance is used to compose interfaces and define ways to compose objects to obtain new functionalities.
Patterns included in this category are:
* Adapter Pattern [(example)](https://dev.to/jemaloq/design-pattern-in-python-4-adapter-pattern-g74)
* Composite Pattern
* Decpratpr Pattern
* Proxy Pattern [(example)](https://dev.to/jemaloq/design-pattern-in-python-5-proxy-pattern-44mf)
* Flyweight Pattern
* Facade Pattern
* Bridge Pattern

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/pr3fs9938tsfc4j5m09h.jpg)

### Behavioral Patterns

Behavioral Patterns are specifically concerned with communication between objects. 

Patterns included in this category are:
* Template Pattern
* Interpreter Pattern
* Strategy Pattern
* State Pattern [(example)](https://dev.to/jemaloq/design-pattern-in-python-3-state-pattern-1ekh)
* Observer Pattern [(example)](https://dev.to/jemaloq/design-pattern-in-python-2-observer-j4)
* Memento Pattern
* Mediator Pattern [(example)](https://dev.to/jemaloq/design-pattern-in-python-6-mediator-pattern-b7d)
* Command Pattern
* Visitor Pattern
* Chain of Responsibility
* Iterator Pattern

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/mi5oqsfddro49vvpae2n.jpg)



####Reference:
  https://www.tutorialspoint.com/design_pattern/design_pattern_overview.htm