Thursday, September 4, 2008

What are design patterns

The following are some of the defintions of Design patterns :
Design patterns constitute a set of rules describing how to accomplish certain tasks in the realm of software development. (Pree 1995)
Design patterns focus more on reuse of recurring architectural design themes, while frameworks focus on detailed design and implementation. (Coplien and Schmidt 1995)
A pattern addresses a recurring design problem that arises in specific design situations and presents a solution to it. (Buschmann et al. 1996)
Patterns identify and specify abstractions that are above the level of single classes and instances or of components. (Gamma, Johnson, and Vlissides, 1993)

To define design patterns in simple words they are "popular solutions for common design problems". They are very helpful in designing architecture and they also increase ease of communication among the developers.

GoF Essential Elements Of Design Patterns are :
1. Pattern Name :Having a concise, meaningful name for a pattern improves communication among developers
2. Problem : What is the problem and context where we would use this pattern?
What are the conditions that must be met before this pattern should be used?
3. Solution : A description of the elements that make up the design pattern
Emphasizes their relationships, responsibilities and collaborations
Not a concrete design or implementation; rather an abstract description
4. Consequen
ces :The pros and cons of using the pattern.
Includes impacts on reusability, portability, extensibility.

Let’s say if you want to implement a sorting algorithm the first thing comes to mind is bubble sort. So the problem is sorting and solution is bubble sort. Same holds true for design patterns.

"Designing object-
oriented software is hard and designing reusable object-oriented software is even harder." - Erich Gamma
Experienced desig
ners reuse solutions that have worked in the past.
Well-structured object-oriented systems have recurring patterns of classes and objects.
Knowledge of the patterns that have worked in the past allows a designer to be more productive and the resulting designs to be more flexible and reusable.
Riehle and Zullighoven in “Understanding and Using Patterns in Software

Development” mention three types of software patterns :
1. Conceptual Pattern: Pattern whose form is described by means of terms and concepts from the application domain.
2. Design Pattern : A Pattern whose form is described by means of software design constructs, such as objects, classes, inheritance and aggregation
3. Programming Pattern (Programming Idiom) : A Pattern whose form is described by means of programming language constructs.

The Gang of Four (GoF) patterns are generally considered the foundation for all other patterns. The GoF design patterns are “descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context.
They are categorized in three groups:
1. Creational,
2. Structural,
3. Behavioral.

No comments: