Click here to Skip to main content
15,885,941 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
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 
GeneralRe: Dependency Injection mystery, and history... Pin
Adam O'Neil26-May-22 5:16
Adam O'Neil26-May-22 5:16 
The first time I saw DI in action, I was horrified and discouraged. It really broke my heart that that was what modern software had become. In this application, there were controller constructors with upwards of 40 arguments each -- tons of services being injected, many with very similar names (DocumentService, WebDocumentService, ExtendedDocumentService). The problem was very much in how the features were factored into services. But there was also a deeply irrational mania about this -- like people sincerely believed that having tons of services made your project "easy to maintain." So, this really soured my view of DI for a long time. There was a similar craze around interfaces and extracting an interface for every single class. There was a religious belief that this made your code "easy to maintain" because of the "D" in SOLID. ("D"epend on interfaces, not concrete classes.)

The thing about this is there is a good case for DI, but you have to strip away the dogma and apply it smartly. And not every class or service needs and interface. Yes, it's a good idea to minimize biz logic in your controllers (for example) to assure testability. And when you get into testing, you'll find that -- yes -- you need to pay attention to what various classes depend on. Interfaces are a miracle when you have truly more than one implementation of a service, but they are just clutter (mental and physical) if you think they belong absolutely everywhere.

So, today I see the benefit of DI, but I had to learn it in a cleansheet way and see the benefits on my own. The abusive implementation I had to deal with early on set me back a long time.
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 
JokeSo I had to go to the store to get 6 bottles of Sprite... PinPopular
Sander Rossel25-May-22 1:16
professionalSander Rossel25-May-22 1:16 

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.