Why should you learn design patterns?

Throughout a life of a developer there must be design patterns in the process of any project with a team of even by himself or herself. Design patterns are used so much that even you have used one without even knowing; so, if you learn more about them, there will be a new resource which will make a big difference to your projects and work.

To answer the question of why should you learn design patterns, you need to understand what is it and what does it consist of? The first answer lays on a similar concept which is an algorithm. Most of the time, design patterns are mistaken as algorithms because of the similarity. We know that an algorithm defines a clear set of actions that achieve some goal. While a design pattern has a more high-level description of a solution. The pattern is a general concept for solving a particular problem which is used to develop the main solution of the program.

What does a design pattern consist of?

To have a more refined concept of design patterns there are sections or descriptions which make a design pattern what it is. Those descriptions are the following:

  • Intent: Description of the problem and the solution.
  • Motivation: In-depth description of the problem and the way the pattern can resolve it.
  • Structure: Relations inside the pattern which describes each part of it to make the whole pattern.
  • Code Example: To get the idea with an even more actual example to be clearer.

Some design pattern may use other sections not mentioned but most of them use them. The main use of these descriptions is to make step by step the pattern and compare it with the sections to make sure it works properly and has the structure well made.

Fibonacci pattern, by Ryan Ewers

Classification of patterns

Even though most of patterns consist of the same sections and descriptions, there are multiple classifications by intent which differentiate from one another. These classifications do not apply to the basic or low-level patterns. They only apply to the high-level patterns which are called architectural patterns.

There are three main classifications by intent in design patterns which are the following:

  • Creational patterns: Consist of the reuse of existing code with the ability to have an object creation mechanism.
  • Structural patterns: Consist of making flexible and efficient structures while assembling object and classes to make even larger structures.
  • Behavioral patterns: Consist of effective communication and assignments of responsibilities between objects.

Antipatterns also exist

Design patterns are powerful tools and concepts that we can use to develop a solution to a problem, but the antipatterns also exist, and they are defined in many ways as a bad practice of design patterns.

The main concept of antipatterns start with the practice of a good pattern in the wrong context, this happens when the developer does not have the sufficient knowledge to solve this particular problem, so the pattern applied will not be the right one.

In the end, antipatterns are used in a good way when refactoring and trying to find the right perspective to a pattern to be made.

References:

Make today count,

You’ll never get it back

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

WordPress.com.

Up ↑

Create your website at WordPress.com
Get started
%d bloggers like this: