Design Patterns 101

An Introduction Design Patterns

“Finding patterns is the essence of wisdom.” Dennis Prager

Photo by Peter F on Unsplash

You have already heard of Design Patterns before for sure if you are into Software Engineering. The sole concept of a pattern is captivating for Engineers since a pattern is the repeated or regular way in which something happens or is done.

The original concept of Design Patterns was originated in the late 70s being composed by Christopher Alexander and colleagues. Alexanders work was brought up to the Software Engineering field in 1995 by the Mythical Gang of Four(GoF) in the book, Design Patterns (Elements of Reusable Object-Oriented Software), the Gang of Four was constituted by:

  • Erich Gamma
  • Richard Helm
  • Ralph Johnson
  • John Vlissides
via Amazon.com

This group of four people did something amazing, being able to transpose such a very ample concept to the Software Engineering field, the adoption of the concepts present in this book is still widely acknowledged by the Software Engineering community and can be considered one of the core skills that a strong Software Engineer must master.

Their book is one of the top best-sellers in Software Engineering, being still very relevant even after 26 years since its release, this shows how disruptive their work was.

So, what are exactly Design Patterns after all? In the GoF book's preface, there is a sentence that, in my opinion, is the best definition of Software Design Patterns.

It’s a book of design patterns that describes simple and elegant solutions to specific problems in objectoriented software design.

There isn’t any wizardry regarding Design Patterns at all, they are just simple solutions to well-known problems that Software Engineers face every day, we can consider them as abstractions for recurring challenges.

One of the awesome aspects of Design Patterns, in my opinion, is that they aren’t in any way oriented to a specific programming language but to the programming paradigm, this means that even in modern-day object-oriented programming languages the principles present in the book can be applied and help you bring a better solution in the end.

In this book, the GoF defined a total of 23 Design Patterns, casually known as the Original Design Patterns. Many more Design Patterns have come before the book's release but in this article, we’ll be focused on the original ones.

The Original 23 Design Patterns were divided into 3 main categories that represent the scope in which each one of these takes action, the categories are Creation, Structure, and Behavior.

I won’t enter in much detail for each one of these categories since there will be further articles fully dedicated to each one of these categories.

Creational Patterns

In object-oriented programming, we are constantly creating and disposing of our objects, a good programmer knows how to give its code the ability to be flexible enough to automatically decide when, how, and where to create its objects.

One common anti-pattern in software development is explicit object creation, this category scope is to do that for you, dealing with the process of object creation. The GoF described 6 Creational Patterns in the book that can help us in the creation of our Objects and enhance the flexibility in this process. These are:

  • Simple Factory
  • Factory Method
  • Abstract Factory
  • Singleton
  • Builder
  • Prototype

Structural Patterns

A house is as good as its structure because its structure is what supports it and makes it endure storms and extraordinary times.

This is also true in Software Engineering, a Software System is as good as its structure, if its structure isn't strong enough from the beginning it will be very much difficult to make changes and extend the system.

Structural Design Patterns help us building a strong structure in our applications, it help us with the composition of the multiple entities that make our application run ensuring that they are well organized and everything is where it belongs making in structure whole.

  • Adapter
  • Bridge
  • Composite
  • Decorator
  • Façade
  • Flyweight
  • Proxy

These are the original 7 Structural Design Patterns.

Behavioral Patterns

Last but not least, the Behavioral Design Patterns handle the communication between the multiple entities in a system. Think about Behavioral Design Patterns as the Gatekeepers of the boundaries between the entities that compose a system, these control the assignment of responsibilities between the objects.

There are a total of 10 original Behavioral Design Patterns.

  • Chain of Responsibility
  • Command
  • Interpreter
  • Iterator
  • Mediator
  • Observer
  • State
  • Strategy
  • Template Method
  • Visitor

So we visited the 3 Design Patterns categories and the original 23 Design Patterns, now you have a high-level understanding of what are Design Patterns, how they were split into categories by the GoF, and which design patterns each category has. The following image condenses the information detailed above in the article.

GoF Original Design Patterns

As was already mentioned in this article this was just an introduction to Design Patterns, in the next steps of this adventure, we will have dedicated articles to each Design Pattern category with more detail and with code implementation on how one can apply a certain Design Pattern to solve a real known issue. Stay tuned for the next articles of this series.

Nelson out!

Tackling big problems with simple solutions. Software Engineer @ Farfetch http://linkedin.com/in/nelson-parente

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store