mardi 17 octobre 2023

Which class implements the factory method?

Is the factory method in the factory method pattern part of a dedicated factory object or part of the business object where I want to use the method?

Basically, will I need to inject a factory object from where I create objects or does the object become a factory itself and I simply call the implemented method to create an object?

In the first case I don't see the advantage of a factory method over a simple factory object where I can e.g. animalFactory.createDog().

Aucun commentaire:

Enregistrer un commentaire