mardi 9 août 2016

Delegate factory method to abstract class

According to Factory Method pattern, we delegate object creation to a separate class. Let's say I have abstract class A and some implementors. Implementation is loaded from configuration file with reflection and thus we still operate with type A. I wonder if there is anything wrong with creating static creation method in abstract class. Any comments? The benefit of it is that no additional class is needed. You could argue that besides main functionality it also has the responsibility of creating subtyped objects - would that really violate S principle from SOLID?

Aucun commentaire:

Enregistrer un commentaire