The Factory Design Pattern is a creational pattern that provides a way to create objects without specifying the exact class of the object that will be created. It uses factory methods to deal with object creation. The factory pattern keeps the code for creating the objects isolated and makes it independent of the classes that create the objects. This makes the code more flexible by minimizing changes needed when new types are introduced.
2. Why factory pattern?
Provide Similar type object based on the data provided to
the factory class.
Localize the object creation
Minimize changes when new type introduced.