1. Learn the meaning of design patterns

The essence of design pattern is the practical application of object-oriented design principles, and it is a full understanding of the encapsulation, inheritance and polymorphic ing of classes as well as the associative and combinative relations of classes.

Using design patterns correctly has the following advantages:

  • Can improve the programmer’s thinking ability, programming ability and design ability
  • Make the program design more standardized, code preparation more engineering, so that the software development efficiency is greatly improved, thus shortening the software development cycle
  • So that the design of the code can be reused, readability, high reliability, good flexibility, maintainability.


Basic elements of software design pattern

Software design patterns can make people more easy and convenient to reuse successful design and architecture, it usually contains the following a few basic elements: the schema name, alias, motivation, problem and solution, the effect, the structure, role model, cooperative relations, the means of implementation, the application of applicability, known, routines, model extension and related, and so on.

The most critical elements include the following four main parts:

1. Schema name

Each pattern has its own name, usually described in one or two words, and can be named based on the problem, features, solutions, capabilities, and effects of the pattern. The schema name helps us understand and remember the schema, as well as discuss our design.

2, problem,

The question describes the context in which the pattern is applied, that is, when it is used. It explains the design problem and the cause and effect of its existence, as well as a set of prerequisites that must be met.

3. Solutions

The solution to the pattern problem includes the design components, their relationships, and their respective responsibilities and ways of working together. Because a pattern is like a template that can be applied to many different situations, the solution does not describe a specific, concrete design or implementation, but rather provides an abstract description of the design problem and how to solve it with a concrete generic combination of elements (a combination of classes or objects).

4, effects,

It describes the application effects of the pattern and the trade-offs that should be made when using the pattern, namely the advantages and disadvantages of the pattern. It mainly measures the time and space, as well as the influence of the model on the flexibility, expansion and portability of the system, and also considers its implementation. Explicitly listing these effects can be of great help in understanding and evaluating these patterns.