News for hackers. Stuff that matters.
Re:Astonishing Performance of .NET 5 by mumblemumble on Thursday November 12, 2020 @09:47AM (#25070417)
I'd go a step further and say that if calls to the IoC container are scattered all around your code, you're not actually doing DI. You're following the service locator antipattern.

(https://blog.ploeh.dk/2010/02/03/ServiceLocatorisanAnti-Patt...)

Re:Astonishing Performance of .NET 5 by legulere on Thursday November 12, 2020 @03:11PM (#25074286)
Dependency injection is just using passing your dependencies as interfaces, especially in the constructor. Nothing more. Dependency injection frameworks are DI combined with a service locator.

Dependency Injection Frameworks have the same issues: - understanding what is going on is harder than injecting objects by hand. - you have limited control over object lifetimes (when objects are created and disposed). Permanent, scoped and transient might be enough most of the time for a web service, but as soon as you fire off tasks that can outlive the requests or when you use it in different circumstances like UI it’s getting a problem.

Re:Astonishing Performance of .NET 5 by jolux on Thursday November 12, 2020 @03:46PM (#25074749)
The core of a DI container is generally extremely simple — objects are constructed by scanning collections of registered dependency types for matches and constructing them with the same process before passing them on. It has a recursive structure that I would even call elegant.
Re:Astonishing Performance of .NET 5 by gpderetta on Thursday November 12, 2020 @11:48AM (#25071678)
Very much so.

We are currently on a long term process of migrating a large C++ codebase from a service locator model to just passing dependencies through constructors. New code is significantly simpler to both use, understand and test.