lundi 13 août 2018

Should I choose Dependency Injection or Factory Pattern

I am investigating about Dependency Injection. And I found that: most of the examples quoted for usage of Dependency Injection, we can solve using the factory pattern as well.

Could you please help me compare strong/weak point between DI and Factory pattern? Should I always choose Dependency Injection instead of factory pattern? Or it is depend on specified project?

How can I know what is the best solution? What is best practice for that?

Aucun commentaire:

Enregistrer un commentaire