Albert Einstein once said “you don’t understand something until you can explain it to your grandmother”. This must have been difficult for him, not only because of the complexity of his work, but also because by the time he became globally famous, he was already quite elder. Imagine how old his grandmother must have been. A true challenge.
Every software developer should know what a design pattern is as this is one of the tools that makes the difference between someone who can be Cheap Canada goose considered a software craftsman and someone who just codes.
So as part of our never-ending learning process, I am here today to explain what design patterns are as if I were trying to explain it to my grandma. If you can explain them to your grandma also, you can truly say that you got it. Here we go.
“Design patterns are tools. Unlike a hammer that you might wield to craft and manipulate physical elements, however, these are tools for the mind. They are a set of guidelines, strategies, procedures or practical solutions for the most common problems that you can encounter when you have to design your software application.
Technically speaking, design patterns tell you how to structure your whole application, what kind of classes you need (I suppose you’ve already explained to your grandma what are classes and objects in terms of software, for god’s sake, that’s the very basics!), how to implement them, what are their functions inside the application and how to make them work together.
In a typical scenario of our profession, you receive an order from a client, understand what the requirements are and what problems need to be solved. Once you’ve identified what is needed, planning how to deliver those requirements would be the next phase. This is where the software craftsmanship begins. Like a builder selecting his tools to go to work on a house, so should a software developer be selecting the adequate design patterns to solve the existing problems and work to achieve their goals. One single design pattern can be enough to solve one or more problems, but you can also combine some of them to solve problems of higher complexity.
To get a sense of what they are, think about a chef. The design patterns are like their recipes. A chef can innovate and try to make dishes on the fly, but a real professional will always keep a repertoire of well known and tasty recipes, without variation since they were invented, knowing that with those recipes, he will delight any commensal in any situation. Those recipes tells the chef which ingredients to use, how to mix them and how to cook them. The chef just needs to know which recipes to use according to the situation and who is coming for dinner.”
Once you have reached this point, if your grandma is still awake or she got at least half of what I have written here, you deserve those wonderful cookies I am sure she prepared with all her love.
Now, let me be serious.
Design patterns are the result of decades of work, of pits and fails; tons of money invested in research and employer education. They are the knowledge of those people who succeeded and failed before you, the solutions of those people who have already solved your problems.
With design patterns, you can build software that suits every single requirement of your client, with one hundred percent guarantee of performance, if and when you implement them properly of course.
Design patterns allow you to speed up your development process, providing you with best practices to make software scalable and reliable, protecting your software against issues that may not become visible until later in the implementation. Reusing design patterns helps to prevent subtle issues that can cause major problems, and it also improves code readability for coders and architects who are familiar with the patterns.
I hope you get the idea and understand what design patterns are, and what they can do for you, because I can’t emphasise enough how important they are. I am not the most experienced software developer, but I’m learning how to be a software craftsman, how to be productive, and how deliver reliable clean code in an efficient manner, so you can trust me when I say: do yourself a favour, use design patterns and do not reinvent the wheel.