Why object is called factory of object | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why object is called factory of object

23rd Feb 2017, 3:27 PM
Ayush singh
2 Answers
+ 7
A factory allows to create an object by invoking a getter method that returns an instance of that object. You don't need to explicitly invoke the constructor then. A factory is usually provided as an interface. The factory pattern is commonly used to follow the rules of OOP (encapsulation ).
23rd Feb 2017, 4:47 PM
Tashi N
Tashi N - avatar
+ 1
I think I understood what you mean, but could you please post an example? Just to be sure.
23rd Feb 2017, 3:51 PM
Marco Bimbati
Marco Bimbati - avatar