jeudi 21 janvier 2021

Factory method design pattern does not allow for code reuse?

I read that Factory Method is used to 1) decouple the class that needs to create the object from the creational code, and 2) reuse the creational code whenever it is needed.

I don't understand how Factory Method achieves the second point - if we are using inheritance then when creating an object from the Factory class we essentially create a class with the whole functionality of both Factory class and its superclass. Am I missing something?

Aucun commentaire:

Enregistrer un commentaire