Re: DI in MVC

2019-12-03 Thread Greg Keogh
I don't know what environments, platforms and coding styles you guys are using, so it's hard for me to picture how you benefit from DI. I'm mostly writing WPF, Xamarin Forms, Blazor Wasm and WebAPI at the moment (luckily no MVC!), and I don't have any problems that DI can solve. I don't have deep

Re: DI in MVC

2019-12-03 Thread David Burstin
Thanks for your replies. I think I wasn't clear. I *fully* support the use of DI, find it invaluable and also add it if it is missing. What I am talking about is DI Frameworks (IoC containers). *My comment " I avoid DI like the plague" should have been "I avoid IoC containers like the plague".

Re: DI in MVC

2019-12-03 Thread Stephen Price
I'm with Nick on this one. If you have a class that is newing up another class, then you have tightly coupled classes. Might as well move the second class into the first one, as you can't have one without the other. If that's how you code, then you might as well put all of your code into one

Re: DI in MVC

2019-12-03 Thread DotNet Dude
Agree with Nick here. Useful for testing mainly and haven’t found it annoying yet. We don’t bother with tiny apps when writing tests is a waste of time. On Wed, 4 Dec 2019 at 10:34, Nick Randolph wrote: > I’m interested in the opinions regarding the use of DI – why is it that > you avoid it? >

RE: DI in MVC

2019-12-03 Thread Nick Randolph
I’m interested in the opinions regarding the use of DI – why is it that you avoid it? I’m asking because I see cases where I find DI invaluable (eg testing) and almost never find that it gets in the way. I’m interested to know whether the opinions are generated based on bad experiences with

Re: DI in MVC

2019-12-03 Thread David Burstin
Yep. I avoid DI like the plague, but no option in a legacy ASP.net MVC project. Thanks anyway. On Wed, 4 Dec 2019, 09:58 Greg Keogh, wrote: > > No takers? >> > > Sorry I can't help. I only use DI when I'm forced to, or it's really > simply integrated (like in Blazor). I consider DI another form

Re: DI in MVC

2019-12-03 Thread Greg Keogh
> No takers? > Sorry I can't help. I only use DI when I'm forced to, or it's really simply integrated (like in Blazor). I consider DI another form of "magic plumbing" and prefer something closer to the service locator pattern. The problem you're seeing is one I hit when writing Xamarin with

Re: DI in MVC

2019-12-03 Thread David Burstin
No takers? On Fri, 29 Nov 2019, 12:22 David Burstin, wrote: > Hi guys, > > Got a DI question: > > Say I have a class that has the following constructor: > > public MyClass(IAnInterface a, IAnother b, IYetAnother c)... > > In my startup.cs I have: > > services.AddTransient(); > ... > > That all