IoC best practices in large projects

What methods did you find useful for managing the dependencies of large projects with Inversion of Control containers?

Do you download everything in one place or share it?

Do you use multiple containers?

+7
dependency-injection inversion-of-control
source share
1 answer

From an architectural point of view, it’s important to keep a clear focus on where your composition root is . It should be as close as possible to the entry point of the application, and you should compile the entire dependency graph in one place.

Otherwise, there may be confusion regarding liability, and you risk submitting all sorts of subtle errors, because the IFoo instance allowed in one place may or may not coincide with the IFoo instance allowed in another.

If the application is so large that the resolution of the entire dependency graph at a time is simply prohibitively expensive, you can access it using lazy loading times in strategic places (near Aggregated Services ).

It is clear that I always have only one container . (Sometimes I have several parent / child containers in the game to break some circular dependencies, but this is implementation detail.)

+8
source share

All Articles