Design Patterns - Flutter
Tags: flutter, architecture, programming, mobile
Published: 2022-06-23 08:41:12

## Introduction

Across diverse languages and frameworks, some tested and trusted sets of steps/procedures have solved problems in the software world. These processes form the core of many solutions to specific issues. On their own, they are not the solutions to these particular problems, but they form the core upon which various solutions lies upon. These set of steps/patterns are what we refer to as [Design Patterns](https://en.wikipedia.org/wiki/Design_Patterns). 

## What are Design Patterns?

Design patterns are a series of patterns that provides a template or description of how you can solve a common problem. On their own, they are not complete solutions to problems but instead offer an explanation or way to solve a general re-occurring problem in the world of software design. 

As a result of the similarities between issues raised, there was a need for a unified way of solving these common problems. That was what brought up the initial set of design patterns. You might have applied many of these solutions while developing a product(well yeah!). They are solutions that go deep into software development and tend to solve core problems without restricting them to a language or framework.


## Importance of Design Patterns

Design patterns provide you with lots of benefits, some of which include:

- Providing a general standard for communication among developers.
- Reducing development time and speeding up the development process.
- Providing proven solutions to common re-occurring problems.
- Provides best practices to get a clean reusable, and bug-free codebase.
- Providing a core/foundation upon which you can build solutions to re-occurring issues in software design
## Gang Of Four Design Patterns

These are a set of design patterns proposed by four authors: [Erich Gamma](https://en.wikipedia.org/wiki/Erich_Gamma), Richard Helm, [Ralph Johnson](https://en.wikipedia.org/wiki/Ralph_Johnson_(computer_scientist)), and [John Vlissides](https://en.wikipedia.org/wiki/John_Vlissides). They are most often referred to as the Gang of Four. They wrote a book titled [Design Patterns: Elements of Reusable Object-Oriented Software](https://www.amazon.com/gp/product/0201633612/ref=as_li_tl?ie=UTF8&camp=1789&creative=390957&creativeASIN=0201633612&linkCode=as2&tag=triatcraft-20&linkId=XRGUDJCGWC6AJNZM), which introduces the design patterns and gives more information on each. This book was a significant aid for the Software Development world as it tackles many of these problems and how these patterns intend to solve them. There are 23 design patterns proposed in the book, which is divided into three categories

- Structural 
- Behavioural and
- Creational.

We will discuss more on each of these categories in the next section. Note that the "Design" here does not refer to UiUx Designs but is more about the design and development of software. One significant benefit of Design Patterns is that it's not specific to a particular language/framework but can be developed and implemented/used across various programming languages. 

## Categories of Design Patterns

We would look into each design pattern and why they are grouped into these categories. Each of these categories deals with a particular use case, and the patterns under them revolve around the solutions to similar situations in development. Since we can't go deep into each of the 23 design patterns, I have included links to study further each of these patterns and how they can be applied in Flutter. In future articles also, we would go deep into specific design patterns and walk through their implementations using Flutter.

## Creational Design Patterns

These are the design patterns that deal with the way Classes and Objects are created/instantiated. There are five design patterns in the Creational Design Pattern category. They are: 

- [Abstract Factory](https://mkobuolys.medium.com/flutter-design-patterns-11-abstract-factory-7098112925d8)
- [Factory](https://mkobuolys.medium.com/flutter-design-patterns-10-factory-method-c53ad11d863f) 
- [Builder](https://mkobuolys.medium.com/flutter-design-patterns-18-builder-cdc90b222724)
- [Prototype](https://mkobuolys.medium.com/flutter-design-patterns-14-prototype-7d7d18bcf643)
- [Singleton](https://mkobuolys.medium.com/flutter-design-patterns-1-singleton-437f04e923ce)


## Structural Design Patterns

These are design patterns that deals with the way Classes and Objects get composed. It deals with the way objects combine to achieve the desired result. There are seven design patterns under this category, and they include: 

- [Adapter](https://mkobuolys.medium.com/flutter-design-patterns-2-adapter-3f05c02a7c84)
- [Bridge](https://mkobuolys.medium.com/flutter-design-patterns-17-bridge-b31711b629f2)
- [Composite](https://mkobuolys.medium.com/flutter-design-patterns-4-composite-23473cccf2b3)
- [Decorator](https://mkobuolys.medium.com/flutter-design-patterns-16-decorator-bf0dd711f093)
- [Facade](https://mkobuolys.medium.com/flutter-design-patterns-7-facade-eb40434fb973)
- [Flyweight](https://mkobuolys.medium.com/flutter-design-patterns-19-flyweight-3d41cfdf36c)
- [Proxy](https://mkobuolys.medium.com/flutter-design-patterns-15-proxy-af8743b24269)

## Behavioural Design Patterns

These are design patterns that deal with how Objects communicate with one another. There are 11 design patterns in this category. They include:

- [Chain of Responsibility](https://mkobuolys.medium.com/flutter-design-patterns-20-chain-of-responsibility-2ff122624297)
- [Command](https://mkobuolys.medium.com/flutter-design-patterns-12-command-e199172e16eb)
- [Interpreter](https://mkobuolys.medium.com/flutter-design-patterns-8-interpreter-8f15e9de3ee9)
- [Iterator](https://mkobuolys.medium.com/flutter-design-patterns-9-iterator-8da27ee83c17)
- [Mediator](https://mkobuolys.medium.com/flutter-design-patterns-22-mediator-575e7aa6bfa9)
- [Memento](https://mkobuolys.medium.com/flutter-design-patterns-13-memento-b487769cf104)
- [Observer](https://mkobuolys.medium.com/flutter-design-patterns-23-observer-1e1b0ea81d73)
- [State](https://mkobuolys.medium.com/flutter-design-patterns-6-state-be06cb05525c)
- [Strategy](https://mkobuolys.medium.com/flutter-design-patterns-5-strategy-ef9cf5b5b694)
- [Template method](https://mkobuolys.medium.com/flutter-design-patterns-3-template-method-89799d84e378)
- [Visitor](https://mkobuolys.medium.com/flutter-design-patterns-21-visitor-af5def0699be)

Some of these terms may/may not be familiar; you probably might have noticed a few that you have used while developing before; these guides would give you a better understanding of why they are used and what they solve.

## Conclusion

In conclusion, these patterns offer solutions to typical and re-occurring software design and development problems. They do not depend on a particular language/framework. However, they do not present immediate solutions to those problems; they serve as a basis/ground upon which you can build solutions to these problems. A deep understanding of these patterns would impact the quality of your codes and enhance communication between you and other developers. 

If you have any questions about any of them or questions on Flutter, you can
reach me through on any of the platforms listed [here](https://linktr.ee/blazebrain). I would be glad to answer. Cheers!