Design Patterns

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

The authors are often referred to as Gang of Four (English Gang of Four, GoF ). The reason for the emergence of this abbreviation is supposed that the name of the book and the author was too long to quote him in an e -mail. Therefore, it is often abbreviated as " GoF book". In the source code of some open source projects to find comments like " GOF: 175 " (→ Decorator ), thus indicating a particular 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:

In general, the documentation of a design pattern should provide sufficient information on the problem, which deals with the pattern of the context of the application and the proposed solution. Many authors lean on their structure to which the descriptions of the Gang of Four and adapt it to their needs.

Classification

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

After the end of the respective pattern distinguish three groups: The first group of forming pattern refers to the production of objects. So you may want to check about the number of generated objects of a class, or you want the concrete type of the objects produced - depending on the conditions - Customize. The second group comprises structural patterns to allow a simplification of the structure between classes. Complex networks of relationships can be simplified logic, for example through intermediary classes or interfaces. The third group of patterns relates to the behavior of the classes. This is the largest group of patterns. They relate to the cooperation and the exchange of messages by objects.

After their scope, patterns in class and object pattern can be divided. Class patterns describe relationships between classes and build priority inheritance structures. The structures are thus defined at compilation time. In contrast, use object model primarily associations and aggregations for describing relationships between objects. The structures described by them between objects are changed dynamically at runtime.

Production patterns ( creational patterns )

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

  • Class pattern Factory Method ( factory method, virtual constructor )
  • Abstract Factory ( abstract factory, kit)
  • Single piece ( singleton )
  • Builder ( builder )
  • Prototype (prototype )

Structural patterns ( structural patterns )

Structural patterns hold classes and objects together into larger structures. Class pattern hold it together interfaces (types) and implementations (classes), while classify object model objects in a structure. Structures described by class patterns are defined at compile time. The structures described by object pattern are changeable at runtime.

  • Class pattern Adapter ( adapter, wrapper ) ( with adapter class inheritance or adapter)
  • Adapter ( adapter, wrapper ) ( with adapter association or object adapter ).
  • Bridge ( bridge, handle / body )
  • Decorator ( wrapper )
  • Facade ( façade )
  • Flyweight ( flyweight )
  • Composite ( composite)
  • Substitute ( proxy, surrogate )

Patterns of behavior ( behavioral patterns )

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

  • Class pattern Interpreter ( interpreter )
  • Template Method ( template method)
  • Observer ( observer, dependents, publish- subscribe, listener )
  • Visitors ( visitor )
  • Iterator ( iterator, cursor )
  • Command ( command, command, action, transaction)
  • Memento ( memento, token )
  • Strategy ( strategy, policy)
  • Intermediary ( mediator )
  • State (state, objects for state)
  • Chain of Responsibility ( chain of responsibility)

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 E. Johnson, John Vlissides: Design Patterns. Elements of Reusable Object-Oriented Software. Addison -Wesley, Munich 2004, ISBN 3-8273-2199-9.
309761
de