Design patterns help us to create robust applications by solving common problems using known and proven solutions.
We identify something as a pattern when we solve a problem that occurs frequently using a common solution method.
This method of solution is possible to use every time the same problem occurs, turning this approach into a reusable design.
This helps save time by avoiding creating particular solutions for something that has been solved before.
A design pattern is a known way to solve a recurring problem.
This design thus becomes a template that has already been evaluated countless times, so we can trust that they have been tested.
However, we must remember that these templates are proposed to be used in our codes and some cases may require changes to adapt them, but the base of the template already summarizes much work.
A good design allows maintenance without much difficulty because it is known and documented extensively. It facilitates any discussion and analysis that arises about the existing code and also improves the reading for new developers over the code.
How design patterns are classified
There are several types of patterns that can be very useful. Creational, structural, and behavioral. These are just some that I usually use and that I believe can not miss in our daily development routine.
Creational design patterns. Solve problems in instance creation.
Structural design patterns. Solve problems related to class structure.
Behavioral design patterns. Solve problems related to the behavior of a class
In conclusion:
- Design pattern, helps to unify the code developed between different programmers.
- It helps to gain time applying known solutions to common problems.
- Helps to create a readable and maintainable code in the future.