I have been reading up a bit on factories and builders and such, and one thing I noticed was that in most cases, the use of an abstract factory only seems to come up if the programmer has a specific need to create various implementations of an object. My question is, can an abstract factory be used PURELY for it's dependency inversion benefit? An example would be an abstract factory that has a single make method and only has a single type of object to create. Even though I don't need to create variations on this object, I still remove dependency on the concrete object implementation from the calling code. This seems like more than enough reason to use an abstract factory for creating basically any object in the whole application. I imagine this gets tedious, which I suppose is one reason to not go this route, but are there any other reasons?
Aucun commentaire:
Enregistrer un commentaire