Skip to content

ioc containers advice

Daniel Gonzalez Garcia edited this page Mar 9, 2018 · 3 revisions

IoC Containers Advices

  • Do NOT hide the container behind a common library for "easy switching". Minimal common denominator.

  • Minimize the usage of the container by using dependency injection at the composition root, instead of service location.

  • Favor constructor injection.

    • Consider property injection for edge cases
  • Prefer interfaces over abstract classes for dependencies

  • Tests are usually ignorant of the container (except for the tests of the container!)

    • Auto-mocking containers exist, though

Previous | Next

Clone this wiki locally