Design pattern
A design pattern is a general, reusable solution to a common problems in software design
Design patterns are not finished designs that can be translated directly into code. Rather they are templates for how to solve a generalized problem in a way that can be adapted to many different situations.
Naming a design pattern gives a team a shared vocabulary. Saying "use an adapter here" conveys a whole design decision in a few words.
The idea of design patterns was popularized by Design Patterns: Elements of Reusable Object-Oriented Software (1994), by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides – the "Gang of Four". Their book catalogued 23 object-oriented patterns and sorted them into three categories by intent.
- Creational patterns abstract the process of object construction.
- Structural patterns compose classes or objects into larger structures.
- Behavioral patterns assign responsibility and shape how objects communicate.
Creational patterns include:
Structural patterns include:
Behavioral patterns include:
The Gang of Four categories cover object-oriented design at the class and object level. Other families of design pattern address different scales and domains. Architectural patterns operate on whole systems, communication patterns describe how components exchange data, and Martin Fowler’s enterprise application patterns address the structure of business applications.
GRASP is a smaller family focused on responsibility assignment in object-oriented designs. The entries below collect the patterns this garden covers so far.
See also
See also code reuse for how design patterns fit alongside other code reuse strategies, and design principles for the distinction between a reusable solution (a pattern) and a guiding maxim (a principle).
See also anti-patterns and YAGNI, which warn about misuse of design patterns.
References
- Gamma et al. (1994). Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley.
- Fowler, M. (2002). Patterns of Enterprise Application Architecture. Addison-Wesley.