In software development, a pattern (or design pattern) is a written document that describes a general solution to a design problem that recurs repeatedly in many projects. Software designers adapt the pattern solution to their specific project. Patterns use a formal approach to describing a design problem, its proposed solution, and any other factors that might affect the problem or the solution. A successful pattern should have established itself as leading to a good solution in three previous projects or situations.
In object-oriented programming, a pattern can contain the description of certain objects and object classes to be used, along with their attributes and dependencies, and the general approach to how to solve the problem. Often, programmers can use more than one pattern to address a specific problem. A collection of patterns is called a pattern framework.
The design patterns methodology has become increasingly popular among software developers since the early 1990s, due largely to some ground-breaking presentations and books on the subject released to the object-oriented world at trade shows and conventions, notably OOPSLA '94 (the Object-Oriented Programming Systems, Languages, and Applications conference). A book, Design Patterns: Elements of Reusable Object-Oriented Software, by E. Gamma, R. Helm, R. Johnson, and J. Vlissides (known in the industry as the Gang of Four, or GOF) is generally credited with sparking the growing interest in design patterns for use in object-oriented programming. The book contains twenty-three patterns, each with a solution for a recurring problem faced in object-oriented design.
Design patterns include the following types of information:
- Name that describes the pattern
- Problem to be solved by the pattern
- Context, or settings, in which the problem occurs
- Forces that could influence the problem or its solution
- Solution proposed to the problem
- Context for the solution
- Rationale behind the solution (examples and stories of past successes or failures often go here)
- Known uses and related patterns
- Author and date information
- References and keywords used or searching
- Sample code related to the solution, if it helps
The concept of using common patterns to solve other, similar problems is said to have originated in the field of building design and architecture and the published work of architect Christopher Alexander. One of his books is largely credited with this concept, A Pattern Language: Towns, Buildings, Construction, Oxford University Press, 1977.