0

When we use factory pattern and when DI.

Please provide the example where use use Factory pattern and where we use Dependency Injection Pattern.

  • 1
    Possible duplicate of [Dependency Injection vs Factory Pattern](https://stackoverflow.com/questions/557742/dependency-injection-vs-factory-pattern) – qujck Jul 24 '19 at 13:25
  • Also see: https://blogs.cuttingedge.it/steven/posts/2016/abstract-factories-are-a-code-smell/ – Steven Jul 24 '19 at 13:28
  • The book [DI PP&P](https://manning.com/seemann2) contains quite some parts that talk about good and bad use of factories in combination with DI. See for instance [paragraph 5.1.2 Example: Control Freak through factories](https://livebook.manning.com/book/dependency-injection-principles-practices-patterns/chapter-5/41) and [paragraph 6.2 Abuse of Abstract Factories](https://livebook.manning.com/book/dependency-injection-principles-practices-patterns/chapter-6/129). – Steven Jul 25 '19 at 08:15

0 Answers0