dependency-injection

Dependency Injection/Inversion of Control

I am about to dip my toe into DI/IoC for the first time with part of an app we have in production. I've spent the last month or so researching DI/IoC and will most likely use the Castle Windsor Container although NInject may be an option. Any of you folks out there got any advice & guidance on best practices, typical pinch/pain points, g...

Which .NET Dependency Injection frameworks are worth looking into?

Which C#/.NET Dependency Injection frameworks are worth looking into? And what can you say about their complexity and speed. ...

When do you use dependency injection?

I've been using StructureMap recently and have enjoyed the experience thoroughly. However, I can see how one can easily get carried away with interfacing everything out and end up with classes that take in a boatload of interfaces into their constructors. Even though that really isn't a huge problem when you're using a dependency injec...

How to get the libraries you need into the bin folder when using IoC/DI

I'm using Castle Windsor to do some dependency injection, specifically I've abstracted the DAL layer to interfaces that are now being loaded by DI. Once the project is developed & deployed all the .bin files will be in the same location, but for while I'm developing in Visual Studio, the only ways I can see of getting the dependency inj...

Dependency Injection Addiction?

Is there a down side? I feel almost dependent on it now. Whenever a project gets past a certain size almost feel an allergic reaction to standard patterns and immediately re-wire it with a Dependency Injection framework. The largest issue I've found is it can be confusing for other developers who are just learning it. Also, I'd feel mu...

IoC Container Configuration/Registration

I absolutely need to use an IoC container for decoupling dependencies in an ever increasingly complex system of enterprise services. The issue I am facing is one related to configuration (a.k.a. registration). We currently have 4 different environments -- development to production and in between. These environments have numerous confi...

Which single IoC/DI container would you recommend using and why?

I'm asking this question because it's a good way to gauge how the community at large feels about the various containers/frameworks and why. Also, whilst my expertise may lie in .Net development, I am very interested in which frameworks are popular (and why) in other languages. If I feel the need to start digging into Java for instance, t...

Can anyone recommend a IOC Container for C++?

I miss dependency injection more than all the raindrops in the ocean. ...

Where to put the dependency injection framework config file?

I've got a solution with several different projects in it, some are pure class libraries and some are web app projects. If I want my default types to be available to all projects, where should I put the config file for the container? ...

How do I do Dependency Injection in a test project (TFS 2008) using Castle

I'm using Castle Windsor for dependency injection in my test project. I'm trying to create an instance one of my 'Repository' classes. "It works fine on my machine", but when I run a nightly build in TFS, my tests are not able to load said classes. private static readonly WindsorContainer _container = new WindsorContainer(new XmlInterpr...

MEF (Managed Extensibility Framework) vs IoC/DI

What problems does MEF (Managed Extensibility Framework) solves that cannot be solved by existing IoC/DI containers? ...

IoC, Where do you put the container?

I'm using castle windsor for a pet-project I'm working on. I'm starting to notice that I need to call the IoC container in different places in my code to create new objects. This dependency on the container makes my code harder to maintain. There are two solutions I've used to solve this problem I tried to create abstract factories as ...

What is Castle Windsor, and why should I care?

I'm a long-time Windows developer, having cut my teeth on win32 and early COM. I've been working with .Net since 2001, so I'm pretty fluent in C# and the CLR. I'd never heard of Castle Windsor until I started participating in Stack Overflow. I've read the Castle Windsor "Getting Started" guide, but it's not clicking. Teach this old d...

Unit testing code with a file system dependency

I am writing a component that, given a ZIP file, needs to: Unzip the file. Find a specific dll among the unzipped files. Load that dll through reflection and invoke a method on it. I'd like to unit test this component. I'm tempted to write code that deals directly with the file system: void DoIt() { Zip.Unzip(theZipFile, "C:\\fo...

What is dependency injection?

There have been several questions already posted with specific questions about dependency injection, such as when to use it, what frameworks are there for it. However, here's the newbie question: What is dependency injection and when/why should or shouldn't it be used? Edit: While external links for followup reading are always apprecia...

Is there a Dependency Injection framework for PHP4?

I'm stuck on a PHP 4 server, and I would like to start moving an old legacy project to modern Design Patterns, including Dependency Injection. Are there any dependency injection frameworks that will work with PHP 4? ...

What are the benefits of dependency injection containers?

I understand benefits of dependency injection itself. Let's take Spring for instance. I also understand benefits of other Spring featureslike AOP, helpers of different kinds, etc. I'm just wondering, what are the benefits of XML configuration such as: <bean id="Mary" class="foo.bar.Female"> <property name="age" value="23"/> </bean> <b...

Castle-Windsor swapping service at runtime

Let say we defined an interface for tax service as ITaxService, and we got more than one implementation of TaxService (by region) however I wanted to attach a specific tax implementation to a specific customer from the spcific region. Will DI help in this scenario? How? "code snippet would be much appreciate" ...

Difference between Dependency Injection (DI) & Inversion of Control (IOC)

I've been seeing a lot of references Dependency Injection (DI) & Inversion of Control (IOC), but I don't really know if there is a difference between them. I would like to start using one or both of them, but I'm a little confused as to how they are different. ...

taglib -> dependency injection pojo/service how?

Is there a nice way to dependency inject using a jsp taglib? either using ejb 3.0, spring, or guice... I have a lot of services/pojos that I would like to use in my taglibs ...