Design Patterns ( english design patterns ) are proven solution templates for recurring design problems both in architecture and in software architecture and development . They thus represent a reusable template for problem solving that can be used in a certain context. In recent years, the design pattern approach has also attracted increasing interest in the field of human-computer interaction . Originally the term was used in architecture by Christopher Alexander .
Types of design patterns
There are different types of design patterns. The following types were originally distinguished:
- Generation pattern (English creational patterns )
- Used to create objects. They decouple the construction of an object from its representation. The object generation is encapsulated and outsourced in order to keep the context of the object generation independent of the concrete implementation, according to the rule: "Program on the interface, not on the implementation!"
- Structure patterns (English structural patterns )
- Make software design easier with pre-made templates for relationships between classes.
- Behavior patterns (English behavioral patterns )
- Model complex behavior of the software and thus increase the flexibility of the software with regard to its behavior.
Other types were added later for those design patterns that did not fit into any of the three types mentioned. Including, for example
- Object-relational mapping pattern
- Used to store and access objects and their relationships in a relational database.
In a tradition going back to Vitruvius , the architect Christopher Alexander put together a collection of design samples between 1977 and 1979. The main task of these patterns is to involve the residents of the structures to be built in the design process. The approach to design patterns was presented by Alexander as early as 1964 in Notes on the synthesis of form . In architecture, however, this idea has not spread as widely as it did later in software development.
Kent Beck and Ward Cunningham took up Alexander's ideas from architecture in 1987 and developed design patterns for the creation of graphical user interfaces in Smalltalk . A year later, Erich Gamma began his doctorate at the University of Zurich on the general transfer of this method to software development. In parallel, James Coplien worked on pattern-like idioms for C ++ from 1989 to 1991 and published his book Advanced C ++ Idioms in 1991 .
Erich Gamma completed his doctorate in the same year and then went to the United States . There he published the book Design Patterns - Elements of Reusable Object-Oriented Software in 1994 together with Richard Helm , Ralph Johnson and John Vlissides , in which 23 design patterns are described. These four authors are among developers also by her nickname Gang of Four ( Gang of Four , shortly GoF known) and helped with her book design patterns to their breakthrough. Occasionally GoF is also used as a reference for the book in question. Unlike Alexander, who wrote his patterns primarily for laypeople, the GoF patterns are aimed at software developers and not users.
Requirements and benefits
A good pattern should
- solve one or more problems ,
- offer a proven concept,
- based on real designs,
- go beyond the obvious,
- involve the user in the design process,
- Show relationships that encompass deeper structures and mechanisms of a system .
Design patterns usually contain references to other patterns. With the help of these it is possible to develop sample languages .
The primary use of a design pattern is to describe a solution to a particular class of design problem. Another benefit comes from the fact that each pattern has a name. This simplifies the discussion among developers, since one can speak abstractly about a structure. For example, software design patterns - in contrast to idioms - are initially independent of the specific programming language.
If the use of design patterns is documented, there is a further benefit in that the description of the pattern creates a reference to the discussion of the problem context and the advantages and disadvantages of the solution.
The successful use of design patterns in the past can lead one to view the design patterns as a miracle weapon and a guarantee of good design. Inexperienced developers may be inclined to use as many familiar patterns as possible, overlooking the fact that in their case a more elegant solution might be possible without using patterns. Design samples do not guarantee that the design will be good. In this respect, applying too many or inappropriate design patterns is an anti-pattern .
Design patterns are usually collected in so-called pattern catalogs (English "Design Pattern Catalog") following the example of the books by Christopher Alexander and the Gang of Four. These describe the individual patterns like a catalog based on their properties. For example, in the book Design Patterns - Elements of Reusable Object-Oriented Software, these properties are : Task, Other Names, Motivation, Applicability, Structure, Participants, Collaborations, Consequences, Implementation, Example Code, Known Uses, Related Patterns.
In addition to the design sample catalog of the Gang of Four, there are a number of other catalogs. These include the books Patterns of Enterprise Application Architecture , Pattern-Oriented Software Architecture, Volume 1, A System of Patterns , Refactoring To Patterns and the Core J2EE Patterns . See section Literature .
List of patterns
The following table of design patterns contains design patterns from the Gang of Four (colored red), functional behavior patterns from Stuart Sierra (colored blue), and other design patterns from other catalogs. The first three columns represent the subsets into which the design patterns in the Design Patterns book have been categorized. The fourth column contains patterns for the object-relational mapping that were especially shaped by Martin Fowler (colored green). The fifth column contains such design patterns that cannot be assigned to any of the first four columns. It is not complete and partially overlaps with architectural patterns .
Other types of patterns
The work of the Gang of Four has stimulated many authors to publish further. This also gave rise to the problem that a pattern can no longer be easily classified as a design pattern. Rather, there are gradual differences in the granularity of patterns. For example, the Model-View-Controller (MVC) pattern is viewed by some as an architectural pattern , and by others (still) as a design pattern .
- Analysis patterns characterize typical cases of requirements analysis .
- Architecture patterns describe typical software architectures .
- Idioms are patterns that occur below the level of design in programming.
- Communication patterns refer to the communication channels between people in an organization.
- Organizational patterns describe elements of the structures of organizations.
- Anti-patterns describe "how not to do it."
- Integration patterns describe the communication between different systems or between components within a system.
- SOA patterns describe the structure of service-oriented architectures .
Where design patterns are common and well-known approaches to solving problems in software development, anti-patterns are negative examples of solutions that have already been carried out, which give indications as to which errors should be avoided.
After more and more positive experiences were benefiting from successfully completed tasks in software development, the focus was also on identifying and documenting the negative examples, i.e. recurring errors in software development.
- Smart UI
- Design patterns and the creation of the wiki
- object oriented programing
- Plugin (design pattern)
- Principles of object-oriented design
- Prototype (technology)
- Reference model
- Reference architecture
- Florian Siebler: Design Patterns with Java: An Introduction to Design Patterns. Hanser-Verlag, 2014, ISBN 978-3-446-43616-9 .
- Deepak Alur, John Cupri, Dan Malks: Core J2EE Patterns: Best Practices and Design Strategies . Prentice Hall, 2003, ISBN 978-0-13-142246-9 , pp. 528 ( oracle.com [accessed November 22, 2009]). (English)
- Frank Buschmann, Regine Meunier, Hans Rohnert, Peter Sommerlad, Michael Stal : Pattern-oriented software architecture. A pattern system. Addison-Wesley-Longman, Bonn 1998, ISBN 3-8273-1282-5 .
- Martin Fowler : Patterns of Enterprise Application Architecture. Addison-Wesley, 2002, ISBN 0-321-12742-0 . (English)
- Eric Freeman, Elisabeth Freeman: Head First Design Patterns. O'Reilly, 2004, ISBN 0-596-00712-4 . (German translation: Design pattern from head to toe. O'Reilly, Cologne 2006, ISBN 3-89721-421-0 .)
- Erich Gamma , Richard Helm , Ralph E. Johnson , John Vlissides : Design Pattern. Elements of reusable object-oriented software . Addison-Wesley, Munich 2004, ISBN 3-8273-2199-9 (English: Design Patterns. Elements of Reusable Object-Oriented Software. ).
- Joshua Kerievsky: Refactoring To Patterns . Addison-Wesley, 2004, ISBN 0-321-21335-1 , pp. 400 ( Catalog of Patterns [accessed November 22, 2009]). (English)
- Helmut Leitner: Pattern Theory - Introduction and Perspectives in the footsteps of Christopher Alexander . Verlag Nausner & Nausner, Graz 2007, ISBN 978-3-901402-50-0 .
- Wolfgang Pree : Design Patterns for Object-Oriented Software Development. Addison-Wesley, ACM Press, 1994, ISBN 0-201-42294-8 . (English)
- Design Pattern Catalog with 10 common design patterns
- Wiki Pages About What Are Patterns . Portland Pattern Repository ; Home page (English)
- Article by Beck and Cunningham (English)
- Design pattern overview
- User interface design patterns
- List of patterns in the Java API
- Helmut Leitner: Working with Patterns - An Introduction from The World of Commons - Patterns of Joint Action . transcript-verlag Bielefeld, 2015, p. 26
- Andreas Zeller: Design sample on st.cs.uni-saarland.de (PDF, p. 2.)
- Erich Gamma , Richard Helm , Ralph E. Johnson , John Vlissides : Design pattern . Elements of reusable object-oriented software. Addison-Wesley, Munich 2004, ISBN 3-8273-2199-9 (English: Design Patterns. Elements of Reusable Object-Oriented Software. ).
- Martin Fowler: Patterns of Enterprise Application Architecture . Addison-Wesley-Longman, Amsterdam 2002, ISBN 0-321-12742-0 .
- Christopher Alexander , Sara Ishikawa, Murray Silverstein, Max Jacobson, Ingrid Fiksfahl-King, Shlomo Angel: Eine Muster- Sprach . Cities, buildings, construction. Löcker, Vienna 1995, ISBN 3-85409-179-6 .