Pattern is something which would seem to show commonality of specific qualities or features when every time we notice or observe the subjects.
For example, we can say, almost every human have pattern of walking, eating, talking and so forth. I was watching this movie, Pi, other day, a mathematical scientist gets a notion of the world and says there is a mathematical pattern in everything that exist on this earth, and he tries to prove it.
So the design pattern for that matter is no different. As a developer, we try to solve the problems every day, and few of the times we tend to solve similar problems frequently.
Imagine a world – when we encounter problem as to one we solved before time, and if we could somehow correlate to the problem which occurred a day or long before. And, imagine a world where if we could correlate our first kind of problem which we could correlate to the problems occurred to other people and were solved those problems. What are we benefiting here? The answer is very simple; we could reuse the solution to the similar problem, and we don’t have to reinvent the wheel every time. It all seems like fantasy world, isn’t it, well not that fantasy it is as we have found the patterns of problems here and solutions to them, so the design patterns come to rescue here.
Design patterns are set of recurring software/software component design problems; the solutions are tested and proved which are maintained by software community.
There are three types of design patterns; it is also called Gang Of Four Patterns (GOF)
- Abstract Factory
- Factory Method
- Chain of Responsibilities
10. Template Methods
- Singleton Pattern:
Problem: Maintain a single instance or state of an object.
UML Class Diagram:
Complexity and Frequency of use:
This is simple, widely used and well known pattern among all of the above.