Is it a good practice to implement the factory method on the interface itself?
Is it scalable? Or unnecessarily coupled?
public interface MyInterface {
default MyInterface createDefaultImpl() {
return new DefaultImpl();
}
}
For sure it would be a problem if the creation method had parameters, adding dependencies/coupling to the interface.
In case of a simple no-args constructor, I`m not really sure.
Aucun commentaire:
Enregistrer un commentaire