About Design Patterns


What is the design pattern?


In software engineering, a design pattern is a general repeatable solution to a commonly occurring problem in software design. A design pattern isn't a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations.

Uses of design patterns


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 improves code readability for coders and architects familiar with the patterns. 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 provide general solutions, documented in a format that doesn't require specifics tied to a particular problem. In addition, patterns allow developers to communicate using well-known, well understood names for software interactions. Common design patterns can be improved over time, making them more robust than ad-hoc designs.

Remember that learning the design patterns will really change how you design your code; not only will you be smarter but you will sound a lot smarter, too.

How many design patterns?


Many. A site says at least 250 existing patterns are used in OO world, including Spaghetti which refers to poor coding habits. The 23 design patterns by GOF are well known, and more are to be discovered on the way.

Note that the design patterns are not idioms or algorithms or components.

What is the relationship among these patterns?


Generally, to build a system, you may need many patterns to fit together. Different designer may use different patterns to solve the same problem. Usually:
  • Some patterns naturally fit together
  • One pattern may lead to another
  • Some patterns are similar and alternative
  • Patterns are discoverable and documentable
  • Patterns are not methods or framework
  • Patterns give you hint to solve a problem effectively


Type Of design patterns?


Creational design patterns
  • design patterns that deal with object creation mechanisms, trying to create objects in a manner suitable to the situation
  • The basic form of object creation could result in design problems or in added complexity to the design. Creational design patterns solve this problem by somehow controlling this object creation

Structural design patterns

structural design patterns are design patterns that ease the design by identifying a simple way to realize relationships between entities.
Behavioral design patterns

behavioral design patterns are design patterns that identify common communication patterns between objects and realize these patterns. By doing so, these patterns increase flexibility in carrying out this communication.


So lets start reading from very begining, Factory Pattern.