1. What are the ideal use cases for method injection?
Method injection is great for the following:
- Functions, frameworks, and shared libraries
- Requesting scoped dependencies, such as context or user credentials
- Stateless objects
- Dependencies that provide context or data in the request and as such are expected to vary between calls.
2. Why is it important not to save dependencies injected with method injection?
Because the dependency is a parameter of the function or method, every call will supply a new dependency. While saving the dependency before calling other internal methods might seem more straightforward than passing the parameter around as a dependency, such practice will cause data races between multiple concurrent usages.
3. What happens if we use method injection too much?
This question is somewhat subjective...