Design Patterns are very popular among software developers. A design pattern is a well-described solution to common software problem.
Some of benefits of using design patterns are :
- Design patterns are already defined and provides industry standard approach to solve recurring problem, so it saves time if we use the design pattern .
- Using design pattern promotes re-usability that leads to more robust and highly maintainable code.
- Since design patterns are already defined, it makes out code easy to understand and debug. It lead to faster development and new members of team understand it easily.
What is a Design Pattern ?
A software design pattern is a general reusable solution to a commonly occurring problem within a given context in software design --- Wikipedia
Java Design Patterns are divided into tree parts : Creational, Structural and Behavioral.
Creational design pattens provide solution to instantiate an object in the best possible way for specific situations. The basic form of object creation could result in design problems or add unwanted complexity to the design. Creational design patterns solve this problem by controlling the object creation by different ways. There are five creational design patterns that we will discuss on :
- Singleton Pattern
- Factory Pattern
- Abstract Factory Pattern
- Builder Pattern
- Prototype Pattern
Structural Patterns provide different ways to create a class structure, for example using inheritance and composition to create a large object from small objects.