字幕列表 影片播放 列印英文字幕 A design pattern in architecture and computer science is a formal way of documenting a solution to a design problem in a particular field of expertise. The idea was introduced by the architect Christopher Alexander in the field of architecture and has been adapted for various other disciplines, including computer science. An organized collection of design patterns that relate to a particular field is called a pattern language. The elements of this language are entities called patterns. Each pattern describes a problem that occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice. — Christopher Alexander The usefulness of speaking of patterns is to have a common terminology for discussing the situations designers already see over and over. Overview A pattern must explain why a particular situation causes problems, and why the proposed solution is considered a good one. Christopher Alexander describes common design problems as arising from "conflicting forces"—such as the conflict between wanting a room to be sunny and wanting it not to overheat on summer afternoons. A pattern would not tell the designer how many windows to put in the room; instead, it would propose a set of values to guide the designer toward a decision that is best for their particular application. Alexander, for example, suggests that enough windows should be included to direct light all around the room. He considers this a good solution because he believes it increases the enjoyment of the room by its occupants. Other authors might come to different conclusions, if they place higher value on heating costs, or material costs. These values, used by the pattern's author to determine which solution is "best", must also be documented within the pattern. A pattern must also explain when it is applicable. Since two houses may be very different from one another, a design pattern for houses must be broad enough to apply to both of them, but not so vague that it doesn't help the designer make decisions. The range of situations in which a pattern can be used is called its context. Some examples might be "all houses", "all two-story houses", or "all places where people spend time". The context must be documented within the pattern. For instance, in Christopher Alexander's work, bus stops and waiting rooms in a surgery center are both part of the context for the pattern "A PLACE TO WAIT". Domain-specific articles Pattern, a way of capturing and communicating design ideas in architecture. Software design pattern, a standard solution to common problems in software design. Architectural pattern, a standard solution to architectural problems in software engineering. Interaction design pattern, used in interaction design / HCI. Pedagogical patterns, documenting good practices in teaching. See also Design Patterns Style guide, repeatable graphic design elements and styles. Design paradigm Software design pattern Anti-pattern a counterpart term, referring to a common situation that creates problems Further reading Alexander, Christopher. A Pattern Language: Towns, Buildings, Construction. Oxford University Press. ISBN 0-19-501919-9. Erl, Thomas. SOA Design Patterns. New York: Prentice Hall/PearsonPTR. p. 864. ISBN 0-13-613516-1. Frank Buschmann, Kevlin Henney, Douglas C. Schmidt "On Patterns and Pattern Languages" Gamma, Helm, Johnson & Vlissides. Design Patterns. Addison-Wesley. ISBN 0-201-63361-2. Jenifer Tidwell. Designing Interfaces Wolfgang Pree. Design Patterns for Object-Oriented Software Development References External links Java Design Patterns Full Tutorial Full collection of design patterns in C++ by Antonio Gulli Design Patterns in Javascript by Tomás Corral