Click here to Skip to main content
15,885,546 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralRe: Dependency Injection mystery, and history... Pin
Greg Utas25-May-22 13:44
professionalGreg Utas25-May-22 13:44 
GeneralRe: Dependency Injection mystery, and history... Pin
jmaida25-May-22 15:21
jmaida25-May-22 15:21 
GeneralRe: Dependency Injection mystery, and history... Pin
Greg Utas25-May-22 15:32
professionalGreg Utas25-May-22 15:32 
GeneralRe: Dependency Injection mystery, and history... Pin
jmaida25-May-22 15:58
jmaida25-May-22 15:58 
GeneralRe: Dependency Injection mystery, and history... Pin
Super Lloyd25-May-22 17:08
Super Lloyd25-May-22 17:08 
GeneralRe: Dependency Injection mystery, and history... Pin
jmaida25-May-22 17:27
jmaida25-May-22 17:27 
GeneralRe: Dependency Injection mystery, and history... Pin
Niels Holst25-May-22 23:49
professionalNiels Holst25-May-22 23:49 
GeneralRe: Dependency Injection mystery, and history... Pin
Sander Rossel26-May-22 0:06
professionalSander Rossel26-May-22 0:06 
Back in 2010 I started doing WinForms development.
I had completely forgotten about it, but now that you mention it, I looked at MEF and MAF at the time and I don't think I understood.
I was especially interested in MAF as you could create add-ins for your application.
Ultimately, I rolled my own (scan a folder for dll's, read the dll's and look for IMyInterface, instantiate implementing types), which was much easier than MAF and did exactly what we wanted.
So anyway, DI isn't much of a thing for WinForms applications, although I'd currently do it by creating instances in the main form and passing them to the other forms, or something like that.
Googling for "WinForms dependency injection" now gives some questionable results and they all use different methods.

In 2015 I started working for a new employer who did web development.
By then I'd read about IoC and DI, even though we didn't use it in WinForms, and this company used it.
However, the method they were using was weird, confusing and added no benefit.
They had this container which they'd instantiate in each page and/or class and then they did something like container.GetInstance<ISomething>().
It didn't work so well when the implementation of ISomething needed constructor parameters (which was, of course, a huge hassle and we didn't use the container in many places, instead instantiating directly completely invalidating our method).
I think they wrote the container thing themselves, and like many subjects there, they'd read about them, knew they had to do something with it, but they didn't understand it.

Then I got assigned to a new project with a coworker from another team and he did understand the concept and he used a third-party DI library in ASP.NET MVC.
That's when it really clicked for me as the pros became immediately apparent.

Then .NET Core came along and it had built-in DI in ASP.NET.
Been using that ever since and it's completely natural for me.

GeneralRe: Dependency Injection mystery, and history... Pin
Adam O'Neil26-May-22 5:16
Adam O'Neil26-May-22 5:16 
GeneralRe: Dependency Injection mystery, and history... Pin
raddevus26-May-22 5:09
mvaraddevus26-May-22 5:09 
GeneralRe: Dependency Injection mystery, and history... Pin
raddevus26-May-22 5:08
mvaraddevus26-May-22 5:08 
GeneralRe: Dependency Injection mystery, and history... Pin
Gerry Schmitz26-May-22 6:26
mveGerry Schmitz26-May-22 6:26 
GeneralRe: Dependency Injection mystery, and history... Pin
abmv26-May-22 8:05
professionalabmv26-May-22 8:05 
GeneralRe: Dependency Injection mystery, and history... Pin
MSBassSinger26-May-22 13:50
professionalMSBassSinger26-May-22 13:50 
GeneralRe: Dependency Injection mystery, and history... Pin
Member 1194113127-May-22 5:33
Member 1194113127-May-22 5:33 
GeneralA much needed vacation PinPopular
kmoorevs25-May-22 7:08
kmoorevs25-May-22 7:08 
GeneralRe: A much needed vacation PinPopular
Maximilien25-May-22 7:28
Maximilien25-May-22 7:28 
GeneralRe: A much needed vacation Pin
OriginalGriff25-May-22 7:56
mveOriginalGriff25-May-22 7:56 
GeneralRe: A much needed vacation Pin
devenv.exe25-May-22 8:31
professionaldevenv.exe25-May-22 8:31 
GeneralRe: A much needed vacation Pin
0x01AA25-May-22 8:56
mve0x01AA25-May-22 8:56 
GeneralRe: A much needed vacation PinPopular
Mike Hankey25-May-22 9:13
mveMike Hankey25-May-22 9:13 
GeneralRe: A much needed vacation Pin
dandy7225-May-22 11:07
dandy7225-May-22 11:07 
GeneralRe: A much needed vacation Pin
DRHuff25-May-22 13:54
DRHuff25-May-22 13:54 
GeneralRe: A much needed vacation Pin
Greg Utas25-May-22 15:33
professionalGreg Utas25-May-22 15:33 
GeneralRe: A much needed vacation Pin
kmoorevs26-May-22 6:10
kmoorevs26-May-22 6:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.