Design pattern (computer science)
From Freepedia
In software engineering, a design pattern is a general solution to a common problem in software design. A design pattern isn't a finished design that can be transformed directly into code; it is a description or template for how to solve a problem that can be used in many different situations. Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved. Algorithms are not thought of as design patterns, since they solve computational problems rather than design problems.
Contents |
History
Patterns originated as an architectural concept by Christopher Alexander. In 1987, Kent Beck and Ward Cunningham began experimenting with the idea of applying patterns to programming and presented their results at the OOPSLA conference that year. In the following years, Beck, Cunningham and others followed up on this work.
Design patterns gained popularity in computer science after the book Design Patterns: Elements of Reusable Object-Oriented Software was published in 1994. That same year, the first Pattern Languages of Programs conference was held and the following year, the Portland Pattern Repository was set up for documentation of design patterns. The scope of the term remained a matter of dispute into the next decade.
Uses
Design patterns can speed up the development process by providing tested, proven development paradigms. Effective software design requires considering issues that may not become visible until later in the implementation. Reusing design patterns helps to prevent subtle issues that can cause major problems and improves code readability for coders and architects familiar with the patterns.
Often, people only understand how to apply certain software design techniques to certain problems. These techniques are difficult to apply to a broader range of problems. Design patterns provide general solutions, documented in a format that doesn't require specifics tied to a particular problem.
Patterns allow developers to communicate using well-known, well understood names for software interactions. Common design patterns can be improved over time, making them more robust than ad-hoc designs.
Classification
Design patterns can be classified based on multiple criteria, the most common of which is the basic underlying problem they solve. According to this criterion, design patterns can be classified into various classes, some of which are:
- Fundamental patterns
- Creational patterns
- Structural patterns
- Behavioral patterns
- Concurrency patterns
- Event handling patterns
- Architectural patterns
Documentation
The documentation for a design pattern should contain enough information about the problem that the pattern addresses, the context in which it is used, and the suggested solution. Nonetheless, authors use their own layouts to document design patterns, and these layouts usually resemble the essential parts. The authors usually include additional sections to provide more information, and organize the essential parts in different sections, possibly with different names.
A commonly used format is the one used by the Gang of Four. It contains the following sections:
- Pattern Name and Classification: Every pattern should have a descriptive and unique name that helps in identifying and referring to it. Additionally, the pattern should be classified according to a classification such as the one described earlier. This classification helps in identifying the use of the pattern.
- Intent: This section should describe the goal behind the pattern and the reason for using it. It resembles the problem part of the pattern.
- Also Known As: A pattern could have more than one name. These names should be documented in this section.
- Motivation: This section provides a scenario consisting of a problem and a context in which this pattern can be used. By relating the problem and the context, this section shows when this pattern is used.
- Applicability: This section includes situations in which this pattern is usable. It represents the context part of the pattern.
- Structure: A graphical representation of the pattern. Class diagrams and Interaction diagrams can be used for this purpose.
- Participants: A listing of the classes and objects used in this pattern and their roles in the design.
- Collaboration: Describes how classes and objects used in the pattern interact with each other.
- Consequences: This section describes the results, side effects, and trade offs caused by using this pattern.
- Implementation: This section describes the implementation of the pattern, and represents the solution part of the pattern. It provides the techniques used in implementing this pattern, and suggests ways for this implementation.
- Sample Code: An illustration of how this pattern can be used in a programming language
- Known Uses: This section includes examples of real usages of this pattern.
- Related Patterns: This section includes other patterns that have some relation with this pattern, so that they can be used along with this pattern, or instead of this pattern. It also includes the differences this pattern has with similar patterns.
Critique
Some feel that the need for patterns results from using computer languages or techniques with insufficient abstraction ability. Under ideal factoring, a concept should not be copied, but merely referenced. But if something is referenced instead of copied, then there is no "pattern" to label and catalog. It is also said that design patterns encourage navigational database-like structures instead of the allegedly cleaner relational approach where such structures are viewpoints instead of hard-wired into programming code. However, critics of the relational approach suggest that it does not integrate well enough with behavior. The level of coupling that should be supplied between behavior and data is a contentious topic.
See also
- Anti-pattern
- Pattern mining
- Pedagogical patterns
- Portland Pattern Repository
- Programming practice
- Refactoring
- Software engineering and List of software engineering topics
References
- Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides: Design Patterns: Elements of Reusable Object-Oriented Software, Addison-Wesley, 1995, hardcover, 395 pages, ISBN 0201633612, Design Patterns CD, 1997 ISBN 0201634988
- Frank Buschmann, Regine Meunier, Hans Rohnert, Peter Sommerlad, Michael Stal: Pattern-oriented Software Architecture, Volume 1: A System of Patterns, John Wiley & Sons Ltd., ISBN 0471958697
- Douglas C. Schmidt, Michael Stal, Hans Rohnert, Frank Buschmann: Pattern-oriented Software Architecture. Volume 2: Patterns for Concurrent and Networked Objects, John Wiley & Sons Ltd., ISBN 0471606952
- Michael Kircher, Prashant Jain: Pattern-oriented Software Architecture. Volume 3: Patterns for Resource Management, John Wiley & Sons Ltd., ISBN 0470845252
- James O. Coplien, Douglas C. Schmidt: Pattern Languages of Program Design, Addison-Wesley, ISBN 0201607344
- John M. Vlissides: Pattern Hatching: Design Patterns Applied, Addison-Wesley, ISBN 0-201-43293-5
- John M. Vlissides, James O. Coplien, Norman L. Kerth: Pattern Languages of Program Design 2, Addison-Wesley, ISBN 0201895277
- Robert C. Martin, Dirk Riehle, Frank Buschmann: Pattern Languages of Program Design 3, Addison-Wesley, ISBN 0201310112
- Neil Harrison, Brian Foote, Hans Rohnert: Pattern Languages of Program Design 4, Addison-Wesley, ISBN 0201433044
- Alan Shalloway, James R. Trott: Design Patterns Explained: A New Perspective on Object-Oriented Design, Addison-Wesley, ISBN 0201715945
- Martin Fowler: Patterns of Enterprise Application Architecture, Addison-Wesley, ISBN 0321127420
- Douglas C. Schmidt, Stephen D. Huston: C++ Network Programming: Mastering Complexity Using ACE and Patterns, Addison-Wesley, ISBN 0201604647
- Eric Freeman, Elisabeth Freeman, Kathy Sierra, Bert Bates: Head First Design Patterns, O'Reilly, ISBN 0-596-00712-4
- Jonathan Kaplan, William C. R. Crawford: J2EE Design Patterns, O'Reilly, ISBN 0-596-00427-3
- Floyd Marinescu: EJB Design Patterns: Advanced Patterns, Processes and Idioms, John Wiley & Sons, ISBN 0-471-20831-0
- Alexander, Christopher et al. A Pattern Language: Towns, Buildings, Construction. Oxford University Press, New York.
- Beck, K.; Crocker, R.; Meszaros, G.; Coplien, J.O.; Dominick, L.; Paulisch, F.; Vlissides, J.;Software Engineering, 1996., Proceedings of the 18th International Conferenceon, 25-30 March 1996.
- Mathijs den Burger. Design Patterns for Networking Applications in Java. March, 2002.
- Cooper, James W., The Design Patterns Java Companion. Addison-Wesley Design Patterns Series. October 1998.
- Cunningham, Ward and Kent Beck. Using a pattern language for programming . In Addendum to the Proceedings of OOPSLA'87, volume 23,5 of ACM SIGPLAN Notices, page 16 May, 1988.
- Fowler, M.; Patterns [software patterns] Software, IEEE, Volume: 20, Issue: 2, March-April 2003. Pages: 56 – 57.
- Kent Beck and Ward Cunningham. Using Pattern Languages for Object-Oriented Programs. Presented at the Workshop on the Specification and Design for Object-Oriented Programming at OOPSLA '87.
- History of Patterns from the Portland Pattern Repository. Accessed on July 28, 2005.
External links
- Java J2EE pattern catalog
- Design Patterns in Java
- Microsoft patterns & practices catalog
- Patterns Catalog
- Design Pattern Toolkit
- XML structural design patterns.
- Perl Design Patterns
- The PatternShare community - community site for sharing patterns.
- TechBookReport - reviews of books on design
- Many design patterns are described in mgrand's bookpatterns and software methodologies
- The list of design patterns is entirely based on a wiki page http://c2.com/cgi/wiki?CategoryPattern.



