mardi 23 juin 2015

Please give an example of factory method pattern

I read the difference between factory pattern and factory method pattern.Factory method pattern defers instantiation of an object to subclasses. Also it is a Factory Method because the children of “Creator” are responsible for implementing the “Create” method. Where as a simple factory is called directly by the class which wants to create an object. But for factory pattern also we can decouple the factory class by adding class registration through reflection and using a layer of subclasses for the objects to be created and keeping the object instantiation logic inside this subclasses. I am not getting an example of the factory method pattern that conforms to the above definition of factory method pattern.Can you please provide me a factory method example?

Aucun commentaire:

Enregistrer un commentaire