Design pattern (book)

from Wikipedia, the free encyclopedia

Design pattern. Elements of Reusable Object-Oriented Software (original title Design Patterns. Elements of Reusable Object-Oriented Software ) is a book published in 1994 by Erich Gamma , Richard Helm , Ralph Johnson and John Vlissides about reusable design patterns and is considered one of the standard works in the field of software engineering .

The authors are often called Gang of Four ( English Gang of Four , GoF called). The reason for this acronym is supposedly that the name of the book and the authors are too long to be quoted in an email . That is why it is often only abbreviated as GoF book . In the source code of some open source projects, there are comments such as GOF: 175, which refers to the Decorator design pattern in the English edition of the book.

structure

The description of a design pattern by the Gang of Four follows the following scheme:

Name and classification
of the pattern.
purpose
of the pattern.
Synonyms
Other familiar names of the pattern.
motivation
(Background) reasons for using the pattern.
applicability
Areas of application for the pattern.
structure
Description of the general structure of the pattern.
Actors involved
Classes involved in the pattern.
Teamwork
of the classes involved.
Consequences
What are the advantages and disadvantages?
implementation
Practical tips, tricks and techniques as well as warnings about mistakes that can easily happen.
Sample code
Source code fragment showing the use of the pattern.
Practical use
Where is the pattern already being used?
Cross references
How does the pattern interact with other patterns?

In general, the documentation for a design sample should provide sufficient information about the problem the sample is addressing, the context of the application, and the proposed solution. Many authors base their structure on the descriptions of the Gang of Four and adapt them to their needs.

classification

The authors classify patterns of the two criteria of the purpose ( purpose ) and the range ( scope ) to which they act.

According to the purpose of the respective pattern, they distinguish between three groups: The first group of creation patterns relates to the creation of objects. For example, you can want to control the number of objects created in a class, or you want to adapt the specific type of objects created - depending on the respective conditions. The second group comprises structural patterns that are intended to simplify the structure between classes. Complex network of relationships can be logically simplified, for example, using mediating classes or interfaces. The third group of behavior patterns concerns the behavior of the classes. This is the largest group of patterns. They relate to the collaboration and message exchange of objects.

Depending on their area of ​​application, patterns can be divided into class and object patterns. Class patterns describe relationships between classes and primarily build up inheritance structures. The structures are thus determined at compilation time. On the other hand, object patterns primarily use associations and aggregations to describe relationships between objects. The structures they describe between objects can be changed dynamically at runtime.

Generation pattern ( creational patterns )

Creation patterns abstract object creation processes. Class patterns use inheritance to vary the class of the object to be created. Object patterns delegate object creation to other objects.

Structure pattern ( structural patterns )

Structural patterns combine classes and objects into larger structures. Class patterns combine interfaces (types) and implementations (classes), while object patterns classify objects in a structure. Structures described by class patterns are defined at compile time. The structures described by object patterns can be changed at runtime.

  • Class pattern
    • Adapter ( adapter , wrapper ) ( adapter with inheritance or class adapter )
  • Object pattern

Behavior ( behavioral patterns )

Behavioral patterns describe the interaction between objects and complex control flows. Class patterns divide control between different classes, object patterns use composition instead of inheritance.

Works

  • Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides: Design Patterns. Elements of Reusable Object-Oriented Software . Addison-Wesley, 1995, ISBN 0-201-63361-2 .
  • Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides: Design Pattern. Elements of reusable object-oriented software . Addison-Wesley, Munich 2004, ISBN 3-8273-2199-9 .

Web links

Individual evidence

  1. Design pattern: elements of reusable object-oriented software . In: heise Developer . Heise Zeitschriften Verlag. July 22, 2010. Retrieved on August 5, 2010: “In this context, it is not surprising that, for example, in some open source source texts only" GoF: 175 "is written, that is, the reference to the decorator pattern in the English edition of the book. "