DEV Community

Cover image for A pattern a day keeps the reviewers away - [Day 0] - What are the design patterns?
Antonio Djigo
Antonio Djigo

Posted on • Updated on

A pattern a day keeps the reviewers away - [Day 0] - What are the design patterns?

Hey 👀✨

During the past few months, I've been working on a back-end project made with Ruby on Rails. Last year I was working as a Front-End developer, I've never had the opportunity to apply design patterns almost anywhere, until now.

It's a pretty useful thing, that probably every developer that works with objects should at least know and practice, and this is why I'm here, to give you (and me!) a daily short post about the different design patterns that exist (or at least, those that are used the most), with an example, and an explanation.

Because doing good code will help you, your workmates, and those who will be in the future.

Teamwork!

Do teamwork!

So, let's start with the basics, how can we start learning about something if we don't know what it is?

This will be a short one.

What is a Design Pattern?

Design patterns will help you solve those most common issues that we find in software design. It's not a matter of copy and pastes to your code. It is not actually "code", a design pattern is just a general idea for solving problems that probably every programmer here has suffered.

You will find many "blueprints" that many developers have polished to give general solutions to general problems. Those blueprints are called Design Patterns.

Instructions

Just follow the instructions, and you'll be just fine!

A short example for this could be that, imagine that you need exclusively one instance of an object, let's say an exclusive role for a user, with global access inside your application, then, you would apply the Singleton Pattern, which ensures that a class has only one instance and provides a global point of access to that instance.

By following the Singleton Pattern rules and examples, you would be able to create your own class following the best procedures to have a clean, easy to test, and flexible code.

And, as there are a lot of problems around here, there are also a lot of awesome solutions to get rid of them, and I'll do my best to show them to you shortly, on the next posts.

And that's it for today, told you it was a short one!

Bye!

I'll try to keep posting every day one of the different patterns that are around. I can't promise I'll fulfil this task every day though!

Aching to know more about design patterns? I really recommend this book, Dive into design patterns. It is pretty complete and you'll find many patterns with real-life examples and solutions. Do not hesitate to visit it if you like it!

Also, you can follow me so you are tuned to whenever I post something through my Twitter account!

Top comments (0)