table of Contents
Preface
I have been asked these questions today, what is a design pattern? Why learn design patterns? The source of the design pattern? In an instant, I felt that the hot design pattern just finished learning is a bit of a waste of learning, yeah, why didn't I notice these problems, so we have to ask ourselves why, combined with 5W2H thinking. Closer to home, let's explore these issues.
1. What is a design pattern (Design Pattern)
Literally understood, it is a system for solving certain types of problems extracted from production experience and life experience. In the field of computer software development, it is a summary of code design experience that is used repeatedly and known to most people.
Simply stated: A model is a set of successful or effective solutions to a certain type of recurring problem in a specific environment.
2. The source of design patterns
①. The origin of the pattern
actually originated in the field of construction. It was developed by Christopher Alexander and his team. Through long-term research in the construction industry, they summarized the reusable solutions in the construction industry and recorded them in the "Architectural In "The Eternal Way", the definition of a pattern is: each pattern describes a problem that constantly arises in a specific environment, and then describes the solution to the problem. In this way, which can be reused countless times There have been successful solutions.
②. Introduce patterns to the
Gang of Four four-member group, and jointly published the book Software Patterns. This book contains a total of 23 design patterns.
Third, why learn design patterns
I summarized a few points:
- Provides a solution for how to solve the problem in different situations
- In order to reusable code, increase maintainability
- I think the most important thing is to learn thinking, (Hey how to solve this problem, what effect can be achieved by such a solution, is there any other solution, etc.)