Detailed Design Patterns: Pattern Summary and Index List

Starting from this article, I will enter the world of design patterns with you.

Previously, I used C# to do a series of articles on the development of WeChat Official Accounts, more of which are native models, helping ape friends understand business processes and basic implementation methods, but the implementation of those classes still uses a process-oriented way of thinking, which is not conducive to later expansion , unable to adapt to large-scale, high-concurrency requirements. After learning the design patterns together, let's reconstruct a set of program code developed by the WeChat official account.

Why Use Design Patterns

Obviously, this is the same as we look at other people's code to learn, to learn the essence of it. Every book on design patterns will tell you that these are all about how to be closed to modification and open to expansion . When we learn something, the important thing is to learn the idea, and the secondary thing is to learn the technique. Translated into a programming language, we learn design patterns to learn how to organize our code reasonably, how to decouple, and how to truly achieve the effect of being closed to modification and open to expansion , rather than memorizing the inheritance patterns of those classes.

If you really learn the design pattern, you will find that when you write code, there is no design pattern in your mind, and you have already mastered it. After the code is written, there are patterns here and patterns there. It's like we don't think about grammar when we speak, but most of what we say meets the grammatical requirements. This is also like when we write a program, we don't always think about the syntax of the program. What we write naturally can be compiled. The reasoning is the same.

However, in order to make reasonable use of design patterns, we should understand a concept called extension points . Extension points are not inherent, they are designed. When we design a software architecture, we also need to design which places can be changed in the future and which places cannot be changed in the future. If your design cannot meet the needs of the real world, then you have to refactor , add useful extension points, and remove useless extension points. This has nothing to do with whether you use design patterns or not, it has something to do with your understanding of specific industries.

How to design an excellent model

As mentioned above, the design pattern is a specific way to realize the seven design principles. As long as the seven design principles are met, we can consider it a good pattern. Then what are the seven principles, as shown in the following figure:

Common Taxonomy and Pattern Names for Design Patterns


Design pattern detailed explanation and case series article index link

Detailed Design Patterns: Seven Principles of Object-Oriented Design

Detailed Design Pattern: Factory Method Pattern

Detailed design pattern: abstract factory pattern

Detailed design pattern: singleton pattern

Detailed Design Patterns: Prototype Patterns

Detailed Design Patterns: Builder Patterns


This series of articles refers to books such as C# Design Patterns (2nd Edition), Java Design Patterns (Crazy Java Alliance Edition), Big Talk Design Patterns, and Zen of Design Patterns. Some codes are directly displayed. If there is any infringement on you, Please let the author of the above book leave a message and I will delete it immediately.

Guess you like

Origin blog.csdn.net/daobaqin/article/details/127043493