Design Patterns are software development solutions for problems that occur in the software design. What’s meant by software design here is actually not UI design but software architecture. These solutions are used to avoid and overcome issues in the software architecture that could lead to inevitable results, and help make the code scalable, reusable, and more efficient in various ways.
Learning these patterns can boost your software development skills and make you code more like a professional. By practicing these patterns and using them in the correct places, you’ll be able to develop stable apps that show off your expertise. Do you know that you might have used design patterns in your application without knowing it? The truth is, we all have. You could’ve even been a software developer for years without ever hearing about this term. It was shocking to me realizing how familiar I was with these patterns when I first learnt them!
This will be a series of articles where I’ll do my very best to describe each design pattern and demonstrate their implementation in Flutter and Dart to learn which design pattern to use and when.This series is based on the famous gof design patterns book “Design Patterns Elements of Reusable Object-Oriented Software” which is in my opinion, the most ideal book about design patterns.
What are design patterns types
We’ve mentioned that these patterns are solutions to problems in software engineering but what is actually meant by that? There patterns are reusable structure or techniques (pattern) of code that are applicable in only given cases to avoid a specific problem. These are not finished code that you can directly add to your software, but more like a template that shows you how to solve an issue in some situation. These are considered as the best practices for software developers which is why I highly recommend you learning them if you haven’t so far.
Benefits of using software design patterns
Implementing design patterns provides a variety of benefits that will make your software more effective and professional. Some of these benefits are:
1. Faster Development
Yes, implementing these techniques can speed up the development process because it provides you with tested techniques that are proven to be effective. It also saves you time as it prevents problems that you may only start encountering later in the implementation process or even way later than that.
Even if you don’t encounter a problem during the implementation process, you could still face an issue when you add a new feature or create an updated version of the software. Practicing these techniques can prevent these issues from coming in you way by building code that is flexible to change making the software safely scalable.
Because these patterns are organized, standard, and reusable code format, it makes you code more readable. Let’s face the truth, we all forget what’s in our code after a while we wrote it so having a readable code can help us and others understand the software structure better.
What are different types of design patterns?
There are a total of 23 design patterns which are classified in 3 different categories based on the problems they solve and their applicability.
1. Creational patterns
This category is for patterns that are specific to object creation techniques and reusability. It has patterns specifying different ways on how classes and objects are instantiated. This category consists of 5 patterns which are:
- Abstract Factory
2. Structural patterns
This category is related to object and classes compositions. In other words, how these elements are assembled together to become a larger element while keeping them efficient and flexible. It contains 7 patterns which are:
3. Behavioral patterns
This category provides mechanisms to enhance how objects communicate with each other and controls the assignments of projects responsibilities. It has 11 patterns known as:
- Chain of Responsibility
- Template Method
We’ll discuss each of design pattern in separate in this series so stay tuned!
This was an overview of design patterns. I hope you got a general idea of what they are and why they’re used. We’ll go through the 23 patterns one by one in separate posts to get a deeper understanding on how to use them in dart and when.
If you find this useful, please don’t hesitate to give it a like and share it to the ones who are seeking to learn design patterns. Happy coding to you all!