0.1 what is the design model?

Source: Internet
Author: User

[Gof · Chapter 2 Conclusion] IntroducesThe Birth and Development History of design patterns: "Architect Christopher Alexander first studied the patterns of buildings and communities and developed a" Pattern Language "to generate them. His work inspired us again and again 』

For most programmers who are not familiar with the construction industry or "Model language,Mode/PatternIs relatively tall. In fact, my personal favorite saying is:Techniques! For example, the solutions or methods of Chinese chess.

Chinese chess metaphor

For example:


Question: In the current situation, how can the red party defeat the black party.

People who can play Chinese chess will surely find a way: they can lock the game by placing a gun behind the hacker. This commonly-used vulnerability killing method has a name called "haidilao Yue ".

Pattern)Is a solution to a problem in a specific environment/condition.

Specific environment: the prerequisite for haidilao is that the red car occupies the Middle Road. In design patterns, a specific environment is part of the problem.

1. Name: "haidilao Yue" represents a Chinese chess board Board (problem), solutions under this board, various changes and solutions. The name of the model, whether it's a player or a programmer, is very helpful for them to discuss issues. These names are part of their professionalism and professional vocabulary. Documentation is an important part of software development. For example, a framework such as spring document is an important document for programmers who learn to use this framework. Using the pattern name in the document allows people who know the design pattern to understand the system more quickly.

When learning Java I/O streams, it will be easy if you know the decoration mode and adapter mode.

2. Problem Description

In general, [gof] "records" or summarizes 23 design patterns. Therefore, it writes: "problem ),Describes when to use the mode....... Sometimes, the problem part includes a series of prerequisites that must be met in the usage mode 』. In [gof · 1. 3. Description of the Design Pattern]: The book describes each pattern based on a specific template. The template includes: pattern name and classification, intent, motivation, applicability, structure, participants, collaboration, effect, implementation, code examples, known applications and related patterns. Therefore, the problem is described"Intention" and "motivation". This is a summary after induction.

Assume that our basic learning method isDeductionIn other words, hopeStart from the problem and find out the corresponding techniques or modelsThen, our problem description may start from a point, and the resulting mode can be applied to more aspects. You know the principles of haidilao Yue. Of course, it's easy to say how the Red-square car soldiers beat the black-square bicycle.

3. Solution

The solution for haidilao Yue is to play games. You can do it yourself if you don't know how to play games.

The design pattern is a problem-solving template in the design, which is usually presented as a class diagram or structure. To make it easier for readers to understand, class diagrams are often added in books or articles. We simply use simple class diagrams formed by the source code of bluej. The source code will be placed in the designpattern folder for readers to download.

4. Evaluation

The evaluation of the chess game method is straightforward, successful or failed. The evaluation of design patterns involves many factors. The basic evaluation is whether the model solves specific problems, so that the design is more in line with the design principles, the software is more flexible and maintainability. However, "software effects mostly focus on measuring time and space", and such evaluations are more targeted at algorithms.

Pattern)Is a solution to a problem in a specific environment/condition.

?Design ModeIs a solution to a design problem in a specific environment or condition. It contains four elements (although we have made some modifications to all four elements ).



0.1 what is the design model?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.