Re:.NET 5.0
by reader_mode on Tuesday November 10, 2020 @08:43PM
(#25054643)
Smells like you're not doing DI properly :)
[ Parent
| on HN ]
Is it a bad design, if it could be held wrong?
Re:.NET 5.0
by reader_mode on Wednesday November 11, 2020 @01:09AM
(#25055947)
Well from the sound of it he's instantiating objects manually 5 levels deep and he has control over all those constructors since he passed a new parameter through all of them.
So it sounds like basically he's not using DI (is just using it to pass stuff to controllers) and is surprised that using a library designed around DI is awkward. The correct solution is use DI to construct that hierarchy and then you can just request IOptions at the bottom/where you need it.
Re:.NET 5.0
by munchbunny on Wednesday November 11, 2020 @09:31AM
(#25058684)
You can hold pretty much anything wrong. Sometimes the onus is on the user to understand the tools. Sometimes the onus is on the tools to not be unnecessarily dangerous. DI is a well understood pattern, it just takes some time to wrap your head around it.