Factory Design Pattern

Factory design pattern belong to the Creational design pattern category which explain how the objects are created. Factory Design Pattern comes with different flavors and we use the flavor as per our convenience. The very common example of Factory design pattern can be found in Spring. Creation of beans in Spring container is done using Factory design pattern only. The implementation is really simple. Create … Continue reading Factory Design Pattern

Singleton Design Pattern

Singleton Design Pattern belong to creational design pattern family and singleton design pattern is used when there is a need of only one instance of class in one container. Like one organization can have only one CEO in company. The singleton pattern is one of the simplest design patterns. It contains only one class which is responsible to instantiate itself and it make sure it creates … Continue reading Singleton Design Pattern

Strategy Design Pattern

This is kind of Behavioral Design Pattern(BDP) and as per the BDP definition, “Behavioral patterns describe how the objects behave when they interact with each other” and this design pattern is used when we have number of options to choose our strategy among available strategies. Example: Lets say you have one List of Employees which you want to sort based on your demand. So the Employee class … Continue reading Strategy Design Pattern

Command Design Pattern

This is kind of Behavioral Design Pattern(BDP) and as per the BDP definition, “Behavioral patterns describe how the objects behave when they interact with each other” and as the name explain this design pattern is used when we give command to some one else to get our job done. Example: When you visit any restaurant, you place an order to waiter not to cook and its … Continue reading Command Design Pattern

Chain of Responsibility Design Pattern

This is kind of Behavioral Design Pattern(BDP) and as per the BDP definition, “Behavioral patterns describe how the objects behave when they interact with each other“. So this design pattern is used when the job is done in pieces and those pieces interact with each other at run time. E.g.  Controller -> Validator -> Service -> DAOImpls. So as you know, Controllers are the entry … Continue reading Chain of Responsibility Design Pattern