In core Java, there are mainly three types of design patterns, which are further divided into their sub-parts:
1. Creational Design Pattern : Creational design patterns are concerned with the way of creating objects.
- Factory Pattern
- Abstract Factory Pattern
- Singleton Pattern
- Prototype Pattern
- Builder Pattern.
2. Structural Design Pattern : Structural design patterns are concerned with how classes and objects can be composed, to form larger structures. The structural design patterns simplifies the structure by identifying the relationships.
- Adapter Pattern
- Bridge Pattern
- Composite Pattern
- Decorator Pattern
- Facade Pattern
- Flyweight Pattern
- Proxy Pattern
3. Behavioral Design Pattern : Behavioral design patterns are concerned with the interaction and responsibility of objects. In these design patterns,the interaction between the objects should be in such a way that they can easily talk to each other and still should be loosely coupled.
- Chain Of Responsibility Pattern
- Command Pattern
- Interpreter Pattern
- Iterator Pattern
- Mediator Pattern
- Memento Pattern
- Observer Pattern
- State Pattern
- Strategy Pattern
- Template Pattern
- Visitor Pattern
Factory Pattern (Creational Pattern)
Singleton Pattern (Creational Pattern)
This pattern involves a single class which is responsible to create an object while making sure that only single object gets created. This class provides a way to access its only object which can be accessed directly without need to instantiate the object of the class.
Proxy Pattern (Structural Pattern)
In proxy pattern, a class represents functionality of another class. In proxy pattern, we create object having original object to interface its functionality to outer world.Facade Pattern (Structural Pattern)
Facade pattern hides the complexities of the system and provides an interface to the client using which the client can access the system. This pattern adds an interface to existing system to hide its complexities.This pattern involves a single class which provides simplified methods required by client and delegates calls to methods of existing system classes.Adapter Pattern (Structural Pattern)
Adapter pattern works as a bridge between two incompatible interfaces. This pattern combines the capability of two independent interfaces.This pattern involves a single class which is responsible to join functionalities of independent or incompatible interfaces. A real life example could be a case of card reader which acts as an adapter between memory card and a laptop. You plugin the memory card into card reader and card reader into the laptop so that memory card can be read via laptop.
Prototype pattern (Creational Pattern)
Prototype pattern refers to creating duplicate object while keeping performance in mind. This pattern provides one of the best ways to create an object.This pattern involves implementing a prototype interface which tells to create a clone of the current object. This pattern is used when creation of object directly is costly. For example, an object is to be created after a costly database operation. We can cache the object, returns its clone on next request and update the database as and when needed thus reducing database calls.
No comments:
Post a Comment