tri_inn

tri_inn

  • NA
  • 1.2k
  • 235.5k

in which scenario people use factory design patter.

Apr 4 2017 9:44 AM

we know that in factory design patter we do not create object of any class directly rather create instance of a class by factory class.

The client is an object that requires an instance
of another object (the product) for some purpose. Rather than creating the
product instance directly, the client delegates this responsibility to the factory.
Once invoked, the factory creates a new instance of the product,
passing it back to the client. Put simply, the client uses the
factory to create an instance of the product.

i read this article https://msdn.microsoft.com/en-us/library/ee817667.aspx?f=255&MSPPError=-2147217396

i am looking for a write up on factory design patter which show me when i need to create instance by factory because we can create instance directly but in factory design pattern instance create via factory. so what is the significance of factory design patter.

so if anyone search google there is many article exist on factory design pattern but i do not find any article which tell me scenario when i will not create instance directly rather will create instance via factory.

so please tell me few scenario with example code from where i can see when people would not prefer creating instance of any class directly rather will create instance via factory.

thanks


Answers (1)