What are Design Patterns?
Inspired by Johnathan Mills Pluralsight course
This short text aims to give a brief overview of Design Patterns. The theme is a common topic in Software Development discussions and is a part of the everyday life of any developer trying to build well-designed software. But what are Design Patterns?
What are Design Patterns?
Design Patterns are our current best guess for some common problems in software development. An example would be: the pedestrian traffic problem or “how can I manage pedestrian traffic in a city?”, urbanist-architects have a current best guess to solve it — the sidewalk. That’s what we could consider to be a Design Pattern.
What does it take to be a Design Pattern?
Needs to solve a problem
Needs to be a proven solution (It has been used before in many contexts and worked)
Needs to be reusable
It can’t be obvious. For example, assigning a value to a variable to store it can’t be considered a Design Pattern
Needs human intervention to be adapted to a certain context
Why use Design Patterns?
Makes communication between developers easier by creating a common vocabulary
Makes the developing process easier by providing reusable solutions for common problems
What are some Design Patterns’ types?
Creational: solves problems related to creating new instances and objects
Structural: solves problems related to having a relationship with an object — either extends or simplifies an object
Behavioral: solves problems related to cooperation between objects — how they manage responsibilities and communication sticking to good design
What are Creational Patterns examples?
Factory: solves the problem of creating multiple similar objects
Singleton: solves the problem of assuring it will be only one instance of an object
Module: solves the problem of organizing methods. Works like a toolbox — grouping similar methods
What are Structural Patterns examples?
Decorator: solves the problem of extending an object's functionality while protecting current behavior.
Façade: solves the problem of simplifying interaction with an object.
Flyweight: solves the problem of reducing memory footprint on application context through sharing data between similar objects
What are Behavioural Patterns examples?
Observer: solves the problem of notifying multiple objects when an event happens
Mediator: solves the problem of communication between objects while maintaining them decoupled
Command: solves the problem of tracking an object's execution history. Also makes implementation more solid, decoupling it from execution
Conclusion
This article only touches the tip of the iceberg concerning Design Patterns discussions. There is even a totally different type not approach here: Concurrency Patterns. To know more follow the links below or start your own journey 🚀.
Learn more about Design Patterns:
● Practical Design Patterns in Javascript
● Design Patterns: Elements of Reusable Object-Oriented Software
● Wikipedia: Software Design Patterns
Written by Bruno Dias