I've just used IoC on a very small project with only one object i needed to test. I'm now starting to implement it into a larger existing project and I'm unsure of something.
Say i have two business objects Student
and Teacher
both have constructor injection for an interface called IUnitOfWork
which has concrete instantiations of SQLUnitOfWork
or InMemoryUnitOfWork
.
So if i'm using this library I can use IoC to construct my object no worries, but what happens when I want to use one inside the other? So say I was lazy loading a property Student.Teacher
and need to get a new Teacher
object, how do I do it?
Something doesn't seem right about using an IoC container to achieve this, but neither does having concrete objects. Using IoC on every single object used seems excessive.