Java Design Patterns — Factory Design Pattern- One of the Most Popular
Design Patterns are independent of any programming language. Here I’m using Java but the same example can be taken for any other language.
These Design Patterns are introduced in order to solve some of the problems that developer might face during object oriented programming. Based on the type of design pattern, they are categorized as Structural, Creational and Behavioral Patterns
In this article, we will go through one of the most popular Creational Design pattern. i.e., Factory Design Pattern

Factory Design Pattern
Suppose we have an interface called Home Appliances and all the classes like Fan, Light, TV implements the interface HomeApplicances.

In my factory class, Say ApplicancesFactory is the place where we create an object of any of these classes and return the object to the calling main method.

Factory Class
This calls for loose coupling. The consumer can choose which object to create and Factory method provides the same.
We can also restrict the creation of the object for the classes as it goes through Factory class.
