Saturday, June 20, 2009

An Introduction to Design patterns

What are design pattrens

Design patterns are commonly defined as time-tested solutions to commonly occurring problems in software design. Design Patterns aren't invented they are discovered. They don't give you code, they give you general solutions to design problems. A design pattern is not a finished design that can be transformed directly into code. A design pattern provides a description for how to solve a problem that can be used in different situations.

Design patterns are grouped mainly into three categories:

Creational patterns:

Creational Patterns deals with object creation mechanisms, they try to create objects in a way that is suitable to a given situation. They are also used for dynamically selecting the class of created objects. Some examples of creational pattrens are
  • AbstractFactoryPattern
  • BuilderPattern
  • FactoryMethodPattern
  • SingletonPattern

Structural patterns:


Structural Patterns are those patterns that helps realizing relationships between entities by identifying simple ways for it, these patterns use various language mechanisms for assembling objects and code structuring. Some examples of structural pattrens are
  • AdapterPattern
  • CompositePattern
  • DecoratorPattern
  • FacadePattern
  • IteratorPattern

Behavioral patterns:


Behavioral Patterns are patterns that identify common communication patterns between objects and realize these patterns. They usually describe how a group of objects collaborate to perform some task that no single object can perform alone. Some examples of behavioral pattrens are
  • CommandPattern
  • IteratorPattern
  • ObserverPattern
  • StatePattern
  • StrategyPattern
  • TemplateMethodPattern
  • VisitorPattern

Benefits of Design patterns:

  • Design Patterns provide a way to solve issues related to software development using a proven solution.
  • Design patterns helps to prevent subtle issues that can cause major problems.
  • Design Patterns facilitates the development of highly cohesive modules with minimal coupling.
  • Design Patterns isolate the variability that may exist in the system requirements, making the overall system easier to understand and maintain.
  • Design Pattern describes the problem, the solution, when to apply the solution, and its consequences.
  • Design Patterns also gives implementation hints and examples.
  • Design Patterns improves code readability for coders and architects who are familiar with the patterns.
  • Design Patterns allow programs to share knowledge about their design.