Design Patterns in Python
![python_tutorials](https://www.deeplearningdaily.com/wp-content/uploads/2020/09/python-600x330.jpeg)
Introduction
Design Patterns are reusable models for solving known and common problems in software architecture.
They’re best described as templates for dealing with a certain usual situation. An architect might have a template for designing certain kinds of door-frames which he fits into many of his projects, and a software engineer, or software architect, should know templates for solving frequent programming challenges.
A good presentation of a design pattern should include:
- Name
- Motivating problem
- Solution
- Consequences
Equivalent Problems
If you were thinking that that’s a pretty fuzzy concept, you’d be right. For instance, we could say that the following “pattern” solves all of your problems:
- Fetch and prepare the necessary data and other resources
- Do the calculations needed and perform the necessary work
- Make logs of what you’re doing
- Release all resources
- ???
- Profit
This is an example of thinking too abstract. You can’t really call this a pattern because it’s not really a good model for solving any problem, despite being technically applicable to any of them (including making dinner).
On the other extreme, you can have solutions that are just too concrete to be called a pattern. For instance, you could wonder