ioc containers advice - Solar-AS/DI-IoC GitHub Wiki

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