DEV Community

Cover image for Design Patterns - Summary

Posted on • Updated on

Design Patterns - Summary


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

If someone is interested in an animation of this graph, refer to these pages: web version and app version

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)
  • Factory Pattern
  • Abstract Factory
  • Builder Pattern
  • Prototype Pattern

Alt Text  

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)
  • Composite Pattern
  • Decpratpr Pattern
  • Proxy Pattern (example)
  • Flyweight Pattern
  • Facade Pattern
  • Bridge Pattern

Alt Text

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)
  • Observer Pattern (example)
  • Memento Pattern
  • Mediator Pattern (example)
  • Command Pattern
  • Visitor Pattern
  • Chain of Responsibility
  • Iterator Pattern

Alt Text


Top comments (0)