Technology Review

Tech Review. All things .NET

Design Patterns

a design pattern is a general reusable solution to a commonly occurring problem within a given context in software design.


A design pattern is not a finished design that can be transformed directly into source or machine code. It is a description or template for how to solve a problem that can be used in many different situations. Patterns are formalized best practices that the programmer must implement themselves in the application. Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved. Many patterns imply object-orientation or more generally mutable state, and so may not be as applicable in functional programming languages, in which data is immutable or treated as such. Design patterns reside in the domain of modules and interconnections. At a higher level there are architectural patterns that are larger in scope, usually describing an overall pattern followed by an entire system. There are many types of design patterns, for instance
  • Algorithm strategy patterns addressing concerns related to high-level strategies describing how to exploit application characteristics on a computing platform.
  • Computational design patterns addressing concerns related to key computation identification.
  • Execution patterns that address concerns related to supporting application execution, including strategies in executing streams of tasks and building blocks to support task synchronization.
  • Implementation strategy patterns addressing concerns related to implementing source code to support
    1. program organization, and
    2. the common data structures specific to parallel programming.
  • Structural design patterns addressing concerns related to high-level structures of applications being developed.

  • History

    Patterns originated as an architectural concept by Christopher Alexander (1977/79). 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 by the so-called ""Gang of Four"" (Gamma et al.), which is frequently abbreviated as ""GOF"". That same year, the first Pattern Languages of Programming Conference was held and the following year, the Portland Pattern Repository was set up for documentation of design patterns. The scope of the term remains a matter of dispute. Notable books in the design pattern genre include:
    • Gamma, Erich; Richard Helm, Ralph Johnson, and John Vlissides (1995). Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley. ISBN 0-201-63361-2.
    • Buschmann, Frank; Regine Meunier, Hans Rohnert, Peter Sommerlad (1996). Pattern-Oriented Software Architecture, Volume 1: A System of Patterns. John Wiley & Sons. ISBN 0-471-95869-7.
    • Schmidt, Douglas C.; Michael Stal, Hans Rohnert, Frank Buschmann (2000). Pattern-Oriented Software Architecture, Volume 2: Patterns for Concurrent and Networked Objects. John Wiley & Sons. ISBN 0-471-60695-2.
    • Fowler, Martin (2002). Patterns of Enterprise Application Architecture. Addison-Wesley. ISBN 978-0-321-12742-6.
    • Hohpe, Gregor; Bobby Woolf (2003). Enterprise Integration Patterns: Designing, Building, and Deploying Messaging Solutions. Addison-Wesley. ISBN 0-321-20068-3.
    • Freeman, Eric T; Elisabeth Robson, Bert Bates, Kathy Sierra (2004). Head First Design Patterns. O'Reilly Media. ISBN 0-596-00712-4.


    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 it also improves code readability for coders and architects who are familiar with the patterns. In order to achieve flexibility, design patterns usually introduce additional levels of indirection, which in some cases may complicate the resulting designs and hurt application performance. By definition, a pattern must be programmed anew into each application that uses it. Since some authors see this as a step backward from software reuse as provided by components, researchers have worked to turn patterns into components. Meyer and Arnout were able to provide full or partial componentization of two-thirds of the patterns they attempted.

    Patterns by Type


    Creational patterns are ones that create objects for you, rather than having you instantiate objects directly. This gives your program more flexibility in deciding which objects need to be created for a given case.
    • Abstract Factory groups object factories that have a common theme.
    • Builder constructs complex objects by separating construction and representation.
    • Factory Method creates objects without specifying the exact class to create.
    • Prototype creates objects by cloning an existing object.
    • Singleton restricts object creation for a class to only one instance.


    These concern class and object composition. They use inheritance to compose interfaces and define ways to compose objects to obtain new functionality.
    • Adapter allows classes with incompatible interfaces to work together by wrapping its own interface around that of an already existing class.
    • Bridge decouples an abstraction from its implementation so that the two can vary independently.
    • Composite composes zero-or-more similar objects so that they can be manipulated as one object.
    • Decorator dynamically adds/overrides behaviour in an existing method of an object.
    • Facade provides a simplified interface to a large body of code.
    • Flyweight reduces the cost of creating and manipulating a large number of similar objects.
    • Proxy provides a placeholder for another object to control access, reduce cost, and reduce complexity.


    Most of these design patterns are specifically concerned with communication between objects
    • Chain of responsibility delegates commands to a chain of processing objects.
    • Command creates objects which encapsulate actions and parameters.
    • Interpreter implements a specialized language.
    • Iterator accesses the elements of an object sequentially without exposing its underlying representation.
    • Mediator allows loose coupling between classes by being the only class that has detailed knowledge of their methods.
    • Memento provides the ability to restore an object to its previous state (undo).
    • Observer is a publish/subscribe pattern which allows a number of observer objects to see an event.
    • State allows an object to alter its behavior when its internal state changes.
    • Strategy allows one of a family of algorithms to be selected on-the-fly at runtime.
    • Template method defines the skeleton of an algorithm as an abstract class, allowing its subclasses to provide concrete behavior.
    • Visitor separates an algorithm from an object structure by moving the hierarchy of methods into one object.

    Design Pattern Resources

About me
Copyright © 2013 - 2014 Nils-Holger Nägele