I’m reading a lot of blogs about development and .Net. One of the blogs I read is from Jimmy Bogard and one of the recent posts there is about guidelines for using Dependency Injection container.
I got involved in comments and one of the commenters was suggesting using
Func<IFoo> as injection instead of injecting the instance for
IFoo. And reasons for that were:
The “captive dependency” problem… objects with more constrained lifetime being held by objects with longer->lived lifetime.
The (wasteful) big-bang object graph problem… when an MVC action only requires 1 dependency, but the dependency graph for all dependencies within the controller need to be resolved.
The occasional property injection… when its 2am and I don’t feel like fixing a circular dependency issue (don’t hate).