So what do you think of dependency injection?
-
I've been playing around with Microsoft's CAB and a little bit with Spring.NET, and besides CAB having a major suckage issue[^] and Spring.NET seeming overly bloated for the majority of use cases, I'm wondering what people think about dependency injection (DI)? Personally, I don't really see the point of these frameworks. I don't think they improve upon the older way of doing things, where you pass in a service manager and you can then request whatever you want from the service manager. Thoughts? Marc
I'm with Jim - I don't like injections. Well, the morphine they gave me in the hospital was fun, but I still didn't like the needle much. All my dependencies are taken in drink.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
-
I've been playing around with Microsoft's CAB and a little bit with Spring.NET, and besides CAB having a major suckage issue[^] and Spring.NET seeming overly bloated for the majority of use cases, I'm wondering what people think about dependency injection (DI)? Personally, I don't really see the point of these frameworks. I don't think they improve upon the older way of doing things, where you pass in a service manager and you can then request whatever you want from the service manager. Thoughts? Marc
The technique? It's fine, when you need it. I don't see the point to using it for everything - if that's what it takes to give you a warm and fuzzy feeling about your tests, then you need help. Call a shrink... or a priest. The frameworks, er, containers? Bloat. I'd rather use a language that didn't require such things...
-
I've been playing around with Microsoft's CAB and a little bit with Spring.NET, and besides CAB having a major suckage issue[^] and Spring.NET seeming overly bloated for the majority of use cases, I'm wondering what people think about dependency injection (DI)? Personally, I don't really see the point of these frameworks. I don't think they improve upon the older way of doing things, where you pass in a service manager and you can then request whatever you want from the service manager. Thoughts? Marc
Marc Clifton wrote:
dependency injection (DI)
Is that when children that you thought had fled the nest for good, pay a surprise visit.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
Marc Clifton wrote:
dependency injection (DI)
Is that when children that you thought had fled the nest for good, pay a surprise visit.
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
Henry Minute wrote:
Is that when children that you thought had fled the nest for good, pay a surprise visit.
Nah, that's just the visitor pattern, when they consume everything in your refrigerator. Dependency Injection is when they move in after losing their job or getting a divorce (along with child dependencies, often enough). Marc
-
I've been playing around with Microsoft's CAB and a little bit with Spring.NET, and besides CAB having a major suckage issue[^] and Spring.NET seeming overly bloated for the majority of use cases, I'm wondering what people think about dependency injection (DI)? Personally, I don't really see the point of these frameworks. I don't think they improve upon the older way of doing things, where you pass in a service manager and you can then request whatever you want from the service manager. Thoughts? Marc
They've always struck me as symptomatic of the "Java way" - if a Java programmer's seen a design pattern they didn't like, it's news to me :-) I would rather pass an interface pointer (or a functor - you don't always need a whole interface) than rely on a big old library and configuration files. But then I've long had an affinity for functional programming[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
-
They've always struck me as symptomatic of the "Java way" - if a Java programmer's seen a design pattern they didn't like, it's news to me :-) I would rather pass an interface pointer (or a functor - you don't always need a whole interface) than rely on a big old library and configuration files. But then I've long had an affinity for functional programming[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
Stuart Dootson wrote:
They've always struck me as symptomatic of the "Java way" - if a Java programmer's seen a design pattern they didn't like, it's news to me
Yeah, they also tend to write code that has every possible interface/factory you can think of, but no implementation of anything real.
My .NET Business Application Framework My Home Page My Younger Son & His "PET"
-
I'm with Jim - I don't like injections. Well, the morphine they gave me in the hospital was fun, but I still didn't like the needle much. All my dependencies are taken in drink.
"A Journey of a Thousand Rest Stops Begins with a Single Movement"
Roger Wright wrote:
All my dependencies are taken in drink.
You need to write a design pattern that models that. Then, using some of the suggestions under Christopher's thread, market the whole thing to fame and fortune.
¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Oh
-
Henry Minute wrote:
Is that when children that you thought had fled the nest for good, pay a surprise visit.
Nah, that's just the visitor pattern, when they consume everything in your refrigerator. Dependency Injection is when they move in after losing their job or getting a divorce (along with child dependencies, often enough). Marc
Excellent!!
Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”
-
I've been playing around with Microsoft's CAB and a little bit with Spring.NET, and besides CAB having a major suckage issue[^] and Spring.NET seeming overly bloated for the majority of use cases, I'm wondering what people think about dependency injection (DI)? Personally, I don't really see the point of these frameworks. I don't think they improve upon the older way of doing things, where you pass in a service manager and you can then request whatever you want from the service manager. Thoughts? Marc
If you want to talk to someone about CAB, Ward Bell[^] is the guy you need to talk to. Make sure you have plenty of time free though, because he is passionate about this stuff and will talk for days if you let him. :-D We've been using the Ideablade[^] DevForce "Classic" framework for a couple of years now and I've met Ward several times at various training sessions. He's a fascinating person to listen to and is very knowledgeable. Personally, I think a lot of the stuff he works on is a bit too academic for most of us in the real world, but it is certainly very interesting and thought-provoking nevertheless.
The StartPage Randomizer - The Windows Cheerleader - Twitter
-
I've been playing around with Microsoft's CAB and a little bit with Spring.NET, and besides CAB having a major suckage issue[^] and Spring.NET seeming overly bloated for the majority of use cases, I'm wondering what people think about dependency injection (DI)? Personally, I don't really see the point of these frameworks. I don't think they improve upon the older way of doing things, where you pass in a service manager and you can then request whatever you want from the service manager. Thoughts? Marc
I haven't understood why we need frameworks for that, and I am tired of the "how IoC can change your life" four color glossies. Is it really that complex?
Don't attribute to stupidity what can be equally well explained by buerocracy.
My latest article | Linkify!| FoldWithUs! | sighist -
I've been playing around with Microsoft's CAB and a little bit with Spring.NET, and besides CAB having a major suckage issue[^] and Spring.NET seeming overly bloated for the majority of use cases, I'm wondering what people think about dependency injection (DI)? Personally, I don't really see the point of these frameworks. I don't think they improve upon the older way of doing things, where you pass in a service manager and you can then request whatever you want from the service manager. Thoughts? Marc
I use it in my web projects and find it really useful. You could create a service manager but what about managing the lifetime of objects? That's where IoC really shines imho. The real fun comes from using IoC along with XML configuration so you can change things on the fly. You also have to recode and recompile your service manager anytime a constructor adds or removes a dependency. Another good feature is property injection. If a class needs logging all we have to do is add public ILogger Log {get; set;} and Log gets set by the IoC after construction. No need to change a constructor or worse 50 constructors for a complex hierarchy of objects just to add logging. In a 4teir application web application -> services -> repository -> data access layer what happens when your DAL needs your HttpContext? Are you going to modify every layer to pass along that value? No problemo. Just declare a dependency in the DAL constructor and the IoC will do the rest. Magic! BTW I wouldn't let Microsoft's CAB taint your view of IoC. That CAB is a behemoth. Some say that even after working with it for a year they still haven't grokked it.
Todd Smith
-
I've been playing around with Microsoft's CAB and a little bit with Spring.NET, and besides CAB having a major suckage issue[^] and Spring.NET seeming overly bloated for the majority of use cases, I'm wondering what people think about dependency injection (DI)? Personally, I don't really see the point of these frameworks. I don't think they improve upon the older way of doing things, where you pass in a service manager and you can then request whatever you want from the service manager. Thoughts? Marc
Dependency injection was like a solution looking for a problem. While loose coupling is nice, I wasn't convinced that such a high degree of loose coupling is necessary or provides any tangible benefits. I changed my mind when I saw something successfully use it: nServiceBus. nServiceBus' use of dependency injection results in an elegant and functional design that is surprisingly easy to use. I'm still not convinced that DI is ready for broad use since I still believe that it's a specialized approach to handle a specialized problem.
Erik Westermann - ArtOfBabel.com - Systems Integration Magazine
Contact Erik for consulting, development, or content creation at +1 416-809-1453 or via wWorkflow.net -
I use it in my web projects and find it really useful. You could create a service manager but what about managing the lifetime of objects? That's where IoC really shines imho. The real fun comes from using IoC along with XML configuration so you can change things on the fly. You also have to recode and recompile your service manager anytime a constructor adds or removes a dependency. Another good feature is property injection. If a class needs logging all we have to do is add public ILogger Log {get; set;} and Log gets set by the IoC after construction. No need to change a constructor or worse 50 constructors for a complex hierarchy of objects just to add logging. In a 4teir application web application -> services -> repository -> data access layer what happens when your DAL needs your HttpContext? Are you going to modify every layer to pass along that value? No problemo. Just declare a dependency in the DAL constructor and the IoC will do the rest. Magic! BTW I wouldn't let Microsoft's CAB taint your view of IoC. That CAB is a behemoth. Some say that even after working with it for a year they still haven't grokked it.
Todd Smith
Todd Smith wrote:
what happens when your DAL needs your HttpContext? Are you going to modify every layer to pass along that value?
Well no, but why not create a simple service container where you can add the HttpContext object, and give that container (in the constructor perhaps?) to classes that need it? Marc
-
Todd Smith wrote:
what happens when your DAL needs your HttpContext? Are you going to modify every layer to pass along that value?
Well no, but why not create a simple service container where you can add the HttpContext object, and give that container (in the constructor perhaps?) to classes that need it? Marc
Marc Clifton wrote:
Well no, but why not create a simple service container where you can add the HttpContext object, and give that container (in the constructor perhaps?) to classes that need it?
Now your DAL has to know about your Service Manager which has to know about ALL of your other interfaces. You've created a coupling between everything in your system. That's like dipping your Jenga puzzle in a giant vat of glue. Or is your Service Manager type agnostic and you're doing a cast during every service request?
Todd Smith
-
I've been playing around with Microsoft's CAB and a little bit with Spring.NET, and besides CAB having a major suckage issue[^] and Spring.NET seeming overly bloated for the majority of use cases, I'm wondering what people think about dependency injection (DI)? Personally, I don't really see the point of these frameworks. I don't think they improve upon the older way of doing things, where you pass in a service manager and you can then request whatever you want from the service manager. Thoughts? Marc
Not used it in anger but been reading around a bit. There are lighter alternatives to what you've tried though, e.g., Unity and Ninject. But I haven't done much more than "Hello World" with either so maybe they suck too?
Kevin
-
I use it in my web projects and find it really useful. You could create a service manager but what about managing the lifetime of objects? That's where IoC really shines imho. The real fun comes from using IoC along with XML configuration so you can change things on the fly. You also have to recode and recompile your service manager anytime a constructor adds or removes a dependency. Another good feature is property injection. If a class needs logging all we have to do is add public ILogger Log {get; set;} and Log gets set by the IoC after construction. No need to change a constructor or worse 50 constructors for a complex hierarchy of objects just to add logging. In a 4teir application web application -> services -> repository -> data access layer what happens when your DAL needs your HttpContext? Are you going to modify every layer to pass along that value? No problemo. Just declare a dependency in the DAL constructor and the IoC will do the rest. Magic! BTW I wouldn't let Microsoft's CAB taint your view of IoC. That CAB is a behemoth. Some say that even after working with it for a year they still haven't grokked it.
Todd Smith
Todd Smith wrote:
what happens when your DAL needs your HttpContext?
[Devil's Advocate Mode] Why would it? :~ [/Devil's Advocate Mode]
You really gotta try harder to keep up with everyone that's not on the short bus with you. - John Simmons / outlaw programmer.
-
Todd Smith wrote:
what happens when your DAL needs your HttpContext?
[Devil's Advocate Mode] Why would it? :~ [/Devil's Advocate Mode]
You really gotta try harder to keep up with everyone that's not on the short bus with you. - John Simmons / outlaw programmer.
-
Not used it in anger but been reading around a bit. There are lighter alternatives to what you've tried though, e.g., Unity and Ninject. But I haven't done much more than "Hello World" with either so maybe they suck too?
Kevin
-
Not used it in anger but been reading around a bit. There are lighter alternatives to what you've tried though, e.g., Unity and Ninject. But I haven't done much more than "Hello World" with either so maybe they suck too?
Kevin
Kevin McFarlane wrote:
But I haven't done much more than "Hello World"
At least we know their natural language, idiom, and GUI services are OK.
You really gotta try harder to keep up with everyone that's not on the short bus with you. - John Simmons / outlaw programmer.
-
I've been playing around with Microsoft's CAB and a little bit with Spring.NET, and besides CAB having a major suckage issue[^] and Spring.NET seeming overly bloated for the majority of use cases, I'm wondering what people think about dependency injection (DI)? Personally, I don't really see the point of these frameworks. I don't think they improve upon the older way of doing things, where you pass in a service manager and you can then request whatever you want from the service manager. Thoughts? Marc
You may want to give a try to StructureMap[^] As others had pointed out, one of the coolest things about IoC is the object's lifetime management. Good luck.