/  244
 
Design pattern (computer science)
From Wikipedia, the free encyclopedia
In software engineering, a
design pattern
is a general reusable solution to a commonly occurringproblem in software design. A design pattern is not a finished design that can be transformed directlyinto code. It is a description or template for how to solve a problem that can be used in manydifferent situations. Object-oriented design patterns typically show relationships and interactionsbetween classes or objects, without specifying the final application classes or objects that areinvolved. Algorithms are not thought of as design patterns, since they solve computational problemsrather than design problems.Not all software patterns are design patterns. Design patterns deal specifically with problems at thelevel of software
design
. Other kinds of patterns, such as architectural patterns, describe problemsand solutions that have alternative scopes.
Contents
1 History2 Practice3 Structure3.1 Domain specific patterns4 Classification5 Documentation6 Criticism6.1 Workarounds for missing language features6.2 Does not differ significantly from other abstractions7 See also8 References9 Further reading10 External links
History
Patterns originated as an architectural concept by Christopher Alexander (1977/79). In 1987, KentBeck and Ward Cunningham began experimenting with the idea of applying patterns to programmingand presented their results at the OOPSLA conference that year.
[1][2]
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 (Gamma et al.). That same year, the firstPattern Languages of Programming Conference was held and the following year, the Portland PatternRepository 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:Fowler, Martin (2002).
Patterns of Enterprise Application Architecture
. Addison-Wesley. ISBN978-0321127426.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.Hohpe, Gregor; Bobby Woolf (2003).
 Enterprise Integration Patterns: Designing, Building,and Deploying Messaging Solutions
. Addison-Wesley. ISBN 0-321-20068-3.Although the practical application of design patterns is a phenomenon, formalization of the conceptof a design pattern languished for several years.
[3]
Practice
Design patterns can speed up the development process by providing tested, proven developmentparadigms. Effective software design requires considering issues that may not become visible untillater in the implementation. Reusing design patterns helps to prevent subtle issues that can causemajor problems, and it also improves code readability for coders and architects who are familiar withthe patterns.In order to achieve flexibility, design patterns usually introduce additional levels of indirection, whichin 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 someauthors see this as a step backward from software reuse as provided by components, researchers haveworked to turn patterns into components. Meyer and Arnout claim a two-thirds success rate incomponentizing the best-known patterns.
[4]
Often, people only understand how to apply certain software design techniques to certain problems.These techniques are difficult to apply to a broader range of problems. Design patterns providegeneral solutions, documented in a format that doesn't require specifics tied to a particular problem.
Structure
Design patterns are composed of several sections (see Documentation below). Of particular interestare the Structure, Participants, and Collaboration sections. These sections describe a
design motif 
: aprototypical
micro-architecture
that developers copy and adapt to their particular designs to solve therecurrent problem described by the design pattern. A micro-architecture is a set of programconstituents (e.g., classes, methods...) and their relationships. Developers use the design pattern byintroducing in their designs this prototypical micro-architecture, which means that micro-architectures in their designs will have structure and organization similar to the chosen design motif.In addition, patterns allow developers to communicate using well-known, well understood names forsoftware interactions. Common design patterns can be improved over time, making them more robustthan
ad-hoc
designs.
Domain specific patterns
 
Efforts have also been made to codify design patterns in particular domains, including use of existingdesign patterns as well as domain specific design patterns. Examples include User Interface designpatterns,
[5]
Information Visualization
[6]
, Secure Usability
[7]
and web design.
[8]
The Pattern Languages of Programming Conference (annual, 1994—) proceedings(http://hillside.net/plop/pastconferences.html) includes many examples of domain specific patterns.
Classification
Design patterns were originally grouped into the categories Creational patterns, Structural patterns,and Behavioral patterns, and described them using the concepts of delegation, aggregation, andconsultation. For further background on object-oriented design, see coupling and cohesion. Forfurther background on object-oriented programming, see inheritance, interface, and polymorphism.Another classification has also introduced the notion of architectural design pattern which may beapplied at the architecture level of the software such as the Model-View-Controller pattern.
NameDescriptionIn
 Design Patterns(book)
In
CodeComplete
[9]
Creational patterns
AbstractfactoryProvide an interface for creating families of related ordependent objects without specifying their concrete classes.YesYesFactorymethodDefine an interface for creating an object, but let subclassesdecide which class to instantiate. Factory Method lets aclass defer instantiation to subclasses.YesYesBuilderSeparate the construction of a complex object from itsrepresentation so that the same construction process cancreate different representations.YesNoLazyinitializationTactic of delaying the creation of an object, the calculationof a value, or some other expensive process until the firsttime it is needed.NoNoObject poolAvoid expensive acquisition and release of resources byrecycling objects that are no longer in useNoNoPrototypeSpecify the kinds of objects to create using a prototypicalinstance, and create new objects by copying this prototype.YesNoSingletonEnsure a class has only one instance, and provide a globalpoint of access to it.YesYes
Structural patterns
AdapterConvert the interface of a class into another interfaceclients expect. Adapter lets classes work together thatcouldn't otherwise because of incompatible interfaces.YesYesBridgeDecouple an abstraction from its implementation so that thetwo can vary independently.YesYes

Share & Embed

More from this user

Add a Comment

Characters: ...

This document has made it onto the Rising list!