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

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

A Beginner’s Guide to Design Patterns

We use design patterns so that we don’t have to write repeated code again and again for same kind of problem. Design pattern is not a class or piece of code. Its a template which should be implemented based on the situation. Design patterns are divided into following categories:- Behavioral, Creational, Structural Behavioral pattern: As the name explain, Behavioral patterns describe how the objects behave … Continue reading A Beginner’s Guide to Design Patterns

Liskov Substitution Principle

Liskov Substitution Principle Explained: Any reference variable attribute of Class that uses pointers to Parent Class must be fully replaceable with other Child objects of that same Parent Class. public class LiskovPrinclple { public static void main(String[] args) { Shape shape = new Square(); } } class Shape { } class Square extends Shape {  } class Circle extends Shape { } class Triangle extends … Continue reading Liskov Substitution Principle