Design Pattern

·

4 min read

Design Pattern

Whenever I sit to code my next new project or just code something for the fun of it, I never really think about what I would need to consider should I decide to refactor it later on. Then during one of my classes, I learnt about design patterns and they sounded interesting, even though I didn’t understand them because the language was too technical lol.

This blog post is the first in a series of design patterns and will be me sharing what I know about design patterns and how they can be used during your software development and maintenance. This is meant to help me and also someone out there learn what design patterns are.

Now that we have gotten past that very awkward introduction lol, let us actually look at what design patterns are in the simplest way.

dp.jpg

What Are Design Patterns?

Before defining what a design a pattern is, we need to understand what a pattern is. A pattern serves as a "guide" to creating good design. If we are to look at the technical explanation of what a design pattern is, we would say,“it is a general, reusable solution to a commonly occurring problem”. However, that definition doesn’t make sense to someone who doesn’t know what a reusable solution is.

That was the technical definition, now let us look at my personal definition. A design pattern is a way to solve problems that are always occurring in any application that we make and design. You can basically use a design pattern to help you make your code easy to maintain after you have developed it.

Having a way to easily maintain our applications is something that is very vital and hence every software developer and engineer should know them especially when dealing with the object-oriented design approach. Communicating using patterns makes it easy for other developers to know what you saying and hence leads to better communication pattern fever.png

So, we looked at what a pattern is and what a design pattern is which leads to us to why we need to know them and finally the different types of patterns that can be used.

Why Should You Learn Design Patterns?

Learning design patterns will help you in various ways such as:

  • You become an expert through experience, reusing solutions that worked for you before.
  • Patterns describe solutions to design problems that occur over and over again.
  • Patterns also record design decisions, alternatives, and trade-offs gained from experience.
  • Once you know the pattern, many design decisions follow.
  • Knowing patterns helps you get designs right faster.
  • Knowing the vocabulary surrounding patterns helps communication between designers, and can ease the documentation effort.
  • Knowing patterns makes designing and maintaining applications easy, flexible and makes code reusable
  • Knowing patterns will get you highly paid because you can solve problems in the easiest ways possible.

If this is not enough reason for you to learn to design patterns then I do not know what will.

Types of Design Patterns

Design patterns can be categorised into three: creational patterns, behavioral patterns and structural patterns.

Creational patterns are used when we want to create new objects in your applications.

Behavioral patterns on the other hand are used to describe the functionality or better yet, the behaviour of each object or class in your application.

Structural patterns are used to ease your design by identifying a simple way of knowing relationship between or among entities.

When you combine all three categories into your application, you are assured that your application will work to its best while also maintaining standards that are accepted by other developers and engineers.

There are a lot of patterns have been developed over the years that fall into one of the three mentioned categories but for this series we will only look at the following:

  1. Strategy Pattern
  2. Expert Pattern
  3. Creator Pattern
  4. Controller Pattern
  5. Façade Pattern
  6. Model View Controller
  7. Proxy Pattern

Thank You for Reading

f693d6332b5468427075a09c6b7d93f8.gif

Thank you for reading up to this point. This is my first post and I hope it was at least helpful to someone out there. I want you to know that we are all learning together and this is just the first step.

Check out my twitter