Design Patterns in Golang

Design Patterns in Golang

In this series I will discuss design patterns in Golang, and why they are important.

What are design patterns (software design patterns) what do they matter?

Software design.

Design patterns allow us to leverage knowledge learned by other developers for solving common occurring problems in software development.

Design patterns were first introduced by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides (aka the Gang of four) in their seminal book "Design Patterns: Elements Of Reusable Object-Oriented Software"

In these series on design patterns in Go We'll look at some key design principles, and walk through examples of how these patterns work.


In the world of design patterns there are three main distinct categories of design patterns:

- Creational design patterns

- Structural design pattern

- Behavioral design pattern

Creational design patterns are a group of patterns (as the name implies) deal with object creation, it groups common practices for creating objects so that object creation is encapsulated from the users that uses the objects. and this group of patterns include:

- The singleton design pattern

- The builder design pattern

- The factory method

- The abstract factory method

- And the Prototype design pattern


Structural design patterns : structural design patterns help shape applications with commonly used structures and relationships. the include:

- The composite design pattern

- The adapter design pattern

- The bridge design pattern

- The proxy design pattern

- The decorator design pattern

- The facade design pattern

- The flyweight design pattern

The last group of patterns is the behavioral patterns: this group of patterns deal with object behavior, how behavior is encapsulated in an object for examples algorithms or executions.

The patterns in this group include:

- The strategy pattern

- The chain of responsibility pattern

- The command design pattern

- The template design pattern

- The memento design pattern

- The interpreter design pattern

- The Visitor, State, Mediator and Observer design patterns


In the next series of articles we will discuss each pattern, their use cases and how you can implement them using Golang which is not object oriented out of the box like C++ or Java.

要查看或添加评论,请登录

社区洞察