What is a design pattern?

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search

Contents

What is a design pattern?

A design pattern is a proven design solution to a common problem faced by software developers. Design patterns became popular with the rise of object oriented analysis and design (OOAD). Design patterns are designed to help developers deliver higher quality, more easily maintained software products in less time and at lower cost.

Design patterns are:

  • encapsulated - They embody design knowledge regarding collaboration of classes and objects, distribution of responsibility, and other design issues.
  • object-oriented - They incorporate OOAD principles—e.g., low coupling, high cohesion.
  • reusable - They are adaptable, flexible, general solutions to classes of problems with broad applicability. Design patterns simplify the task facing the developer.

How are design patterns classified?

Design patterns are categorized to facilitate learning and extending them. They are classified in terms of the underlying problems they address, i.e. according to usage.

The three main design pattern categories are:

  • Behavioral design patterns - characterize the manner of class and object interaction and how responsibilities are distributed among them.
  • Creational design patterns - address the object creation process. Creational design patterns encapsulate knowledge about how, when, and by whom an instance is created.

Design patterns vary both in granularity and level of abstraction.

How are design patterns described?

Typically, a design pattern is described using several of the following items:

  • Pattern name - a brief, descriptive, and unique name to identify the pattern.
  • Classification - a category assignment according to usage (see above).
  • Intent - a description of the goal of the pattern and the reasons for employing it.
  • Also known as (AKA) - patterns are often known by more than one name. Additional names are documented here.
  • Motivation (Forces) - a scenario comprising a problem and a context in which this pattern should be used, i.e. when and where to use this pattern.
  • Applicability - describes various situations (contexts) in which this pattern is usable.
  • Structure - a graphical representation of the pattern, typically in Unified Modeling Language (UML). Primarily, class diagrams and interaction diagrams are used.
  • Participants - a summary of the various classes and objects employed in this pattern and their roles in the design pattern.
  • Collaboration - a description of class and object interactions.
  • Consequences - a description of the results, trade-offs, and any side effects involved in applying this pattern.
  • Implementation - a description of the implementation of the pattern—the pattern "solution". Also provided are notes, suggestions, and techniques helpful in implementing this pattern.
  • Sample code - a source code example of how this pattern can be implemented in a particular programming language.
  • Known uses - a listing of actual usages of this pattern.
  • Related patterns - a listing of related patterns which can be used either in conjunction with or in place of this pattern. Differences between similar patterns are highlighted.

How did design patterns originate?

The history of design patterns is quite short. They originated as an architectural concept proposed by Christopher Alexander in the late nineteen seventies (ca. 1977). Kent Beck and Ward Cunningham experimented with the notion of applying patterns to computer programming in the late nineteen eighties (ca. 1987). Design patterns did not become widely used in computer science until after Design Patterns: Elements of Reusable Object-Oriented Software by the so-called Gang of Four was published in 1994.

See also





Personal tools