Skip to content

Instantly share code, notes, and snippets.

@dasibre
Created October 12, 2017 13:31
Show Gist options
  • Select an option

  • Save dasibre/ecfab11effde9b26b4a1ca9539e29fa2 to your computer and use it in GitHub Desktop.

Select an option

Save dasibre/ecfab11effde9b26b4a1ca9539e29fa2 to your computer and use it in GitHub Desktop.
Dependency injection dos and donts
Dependency injection is effective in these situations:
You need to inject configuration data into one or more components.
You need to inject the same dependency into multiple components.
You need to inject different implementations of the same dependency.
You need to inject the same implementation in different configurations.
You need some of the services provided by the container.
Dependency injection is not effective if:
You will never need a different implementation.
You will never need a different configuration.
If you know you will never change the implementation or configuration of some dependency, there is no benefit in using dependency injection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment