I'm a little confused around the constructor injection pattern and rules. Don't call the container; he will call you .
Can someone explain to me (and possibly someone else) how a real application should get all the benefits of DI using constructor injection? I give for this a few simple and, I think, a general example:
DomainObject
RepositoryObject
DaoObject
The relationship is obvious (I think) - for RepositoryObject you need the DaoObject repository, DomainObject.
Using constructor injection I assume that I can forget (in most cases) the NEW key, but when, where and how do I create new objects (mainly a domain)? Should I write factories for all classes? Should I reference the DI container in this factory?
Best of all, when someone shows me an example of a real application (please, not Asp.Net MVC :)) or draw some project structure.
source
share