DI, dependency-injection, is a design pattern where dependencies (instances of objects, properties) of a component are set through the constructor(s), methods or fields (properties)

learn more… | top users | synonyms

2
votes
1answer
222 views

Sharding with IoC

I've come across a situation where I need to shard a database (Oracle, but that doesn't particularly matter). The gist of the problem is I have written a large-scale system in a fairly standard ...
19
votes
5answers
10k views

What's the best way to build a factory using NInject?

I am pretty comfortable with dependency injection using NInject in MVC3. While working in an MVC3 application, I developed a custom Controller Creation Factory using NInject, so any controller that is ...
7
votes
1answer
630 views

Problem with understanding “seam” word

I'm reading "Dependency Injection in .NET" of Mark Seemann (it's fantastic, and must have) and author often uses word "SEAM", but I can't understand what does it means? Here is an example of using ...
11
votes
2answers
1k views

What is the difference between DI and IoC? [duplicate]

Possible Duplicate: Difference between Dependency Injection (DI) & Inversion of Control (IOC) I'm new to Inversion of Control, Dependency Injection and everything related to these ...
2
votes
2answers
366 views

Is there a better way to design these classes?

I have two business classes: TimesheetDay and TimeSlot. One TimesheetDay can have one or more TimeSlots. The TimesheetDay and TimeSlot classes will be dependent on an object that implements a ...
1
vote
3answers
171 views

Passing a dependency to a controller class

I'm looking for an approach to the following problem: I have a reusable library. It contains a controller class, in the MVC sense. Let's say it's called UserAdministrationController, and it's for ...
2
votes
1answer
437 views

JSP Model 2 Architecture and Dependency Injection

If I'm writing a web application that uses the model 2 architecture, is it possible to use the Google Guice framework (or really any IoC container)? The reason I ask this question is because ...
2
votes
1answer
556 views

Dependency Injection: Only for single-instance objects?

What if I want to also decouple my application, from classes like Product or User? (which usually have more than one instance) Take a look at this example: class Controller { public function ...
-5
votes
1answer
3k views

What are Dependency Injections and why are they useful? [closed]

I have heard of ninject and I have to build a lot of apps that have to integrate with other tools. SO i was wondering what this was and how it is used.
15
votes
2answers
724 views

Is DDD-Lite a pattern language for dependency injection?

I stumbled upon Greg Young's talk 7 Reasons why DDD Projects Fail where he mentions something he calls DDD-Lite at 7:20. Summarizing, he basically says some use DDD as a pattern languages (entities, ...
7
votes
2answers
875 views

c++ Model View Presenter: Where to construct presenter?

I'm using the Model View Presenter (MVP) pattern as described in The Humble Dialog Box paper (pdf) with an MFC project. I'm sure the issue is the same with most GUI toolkits. The thing that's ...
3
votes
2answers
573 views

Which of these is the best strategy for dependency injection?

I am working on a Java project that uses a dependency injection framework built by the company itself. The framework enforces the following naming convention: suppose you have a class Foo that depends ...
9
votes
1answer
1k views

Multiple Zend application code organisation

For the past year I have been working on a series of applications all based on the Zend framework and centered on a complex business logic that all applications must have access to even if they don't ...
3
votes
1answer
378 views

In-process SOA?

Can DI/IoC be used for a simplified, local SOA? I have been reading up on SOA (examples: here, here and here) and it seems that at first a lot of the attention was at interoperability and enabeling ...
5
votes
3answers
511 views

How often do you use DI container in your ASP.NET MVC application

While reading a book, I came across DI(dependency Injector) and the subsequent DI Container tool. Previously, I developed an application following a tutorial on asp.net website which never used such ...
17
votes
6answers
988 views

Should the usage of DI/IoC remove all occurrences of the “new” keyword?

Should the usage of Dependency Injection and an Inversion of Control container remove all occurrences of the "new" keyword from your code? In other words, should every object/dependency, no matter ...
13
votes
1answer
2k views

Domain-Driven-Design - external dependencies in the Entity problem

I'd like to start Domain-Driven-Design, but there are several problems I'd like to solve before starting :) Let's imagine I have a Groups and Users and when user wants to join a group, I'm calling ...
8
votes
3answers
971 views

Keeping an MVC model loosely coupled from the DB?

I like to keep my code testable and have decided to go with the Dependency-Injection strategy for my current MVC framework, which definitely has proven to be a great way to ensure loosely coupled ...
4
votes
1answer
508 views

Understanding the DIP, DI, IoC theory

For about 2 months I've been reading everything I can find for these 3 topics and I'm not yet sure I got it. Dependency Inversion Principle. Means you should always only rely on interfaces and not ...
81
votes
6answers
78k views

What does the Spring framework do? Should I use it? Why or why not? [closed]

So, I'm starting a brand-new project in Java, and am considering using Spring. Why am I considering Spring? Because lots of people tell me I should use Spring! Seriously, any time I've tried to get ...
3
votes
1answer
82 views

Test interface implementation

I have a interface in our code base that I would like to be able to mock out for unit testing. I am writing a test implementation to allow the individual tests to be able to override the specific ...
2
votes
1answer
287 views

Customizing configuration with Dependency Injection

I'm designing a small application infrastructure library, aiming to simplify development of ASP.NET MVC based applications. Main goal is to enforce convention over configuration. Hovewer, I still ...
7
votes
4answers
4k views

Use Dependency Injection For Data Objects?

I'm just learning about dependency injection, and am stuck on something. Dependency Injection recommends sending dependent classes through the constructor, but I'm wondering if this is necessary for ...
17
votes
4answers
2k views

Does “Inversion of Control” promote “Anemic Domain Model”?

When I used IoC Container in my last project, I ended up with anemic entities and most of my business logic in Stateless Services. I have seen projects written by other developers that utilize ...
1
vote
3answers
411 views

Dependency Injection and method signatures

I've been using YADIF (yet another dependency injection framework) in a PHP/Zend app I'm working on to handle dependencies. This has achieved some notable benefits in terms of testing and decoupling ...
44
votes
10answers
5k views

(Why) is it important that a unit test not test dependencies?

I understand the value of automated testing and use it wherever the problem is well-specified enough that I can come up with good test cases. I've noticed, though, that some people here and on ...
3
votes
2answers
450 views

“Don't cross the streams” Database access objects independant of the Data tier in an N-Tier architecture?

I'm adding functionality to our website which performs long-running processes asynchronously using MSMQ. Doing this ansynch, however means we need to notify users when their requests are completed. ...
5
votes
4answers
577 views

How could dependency injection be integrated into the language?

I've been thinking a bit on how dependency injection could be better integrated directly into a C# like language. I've come up with a potential solution I'd like to hear your opinion on. I haven't ...
2
votes
2answers
4k views

Why would I choose Unity over Autofac

I'm looking to start a new application and I want to use Dependency Injection. I have a lot of "Microsoft is the only way to go guys" in our shop so of course Unity is the way they wanted to go. ...
14
votes
6answers
582 views

Do abstractions have to reduce code readability?

A good developer I work with told me recently about some difficulty he had in implementing a feature in some code we had inherited; he said the problem was that the code was difficult to follow. From ...
15
votes
3answers
2k views

Sell me on IoC containers, please

I've seen several recommend use of IoC containers in code. The motivation is simple. Take the following dependency injected code: class UnitUnderTest { std::auto_ptr<Dependency> d_; public: ...
7
votes
2answers
506 views

How do I inject test objects when the real objects are created dynamically?

I want to make a class testable using dependency injection. But the class creates multiple objects at runtime, and passes different values to their constructor. Here's a simplified example: public ...
10
votes
4answers
641 views

Gradual approaches to dependency injection

I'm working on making my classes unit-testable, using dependency injection. But some of these classes have a lot of clients, and I'm not ready to refactor all of them to start passing in the ...
236
votes
13answers
63k views

So Singletons are bad, then what?

There has been a lot of discussion lately about the problems with using (and overusing) Singletons. I've been one of those people earlier in my career too. I can see what the problem is now, and yet, ...
7
votes
3answers
412 views

Recommendations on integrating DI/IoC container into an existing application

I am now faced with integrating an inversion of control (IoC) container into an existing application, and I'm looking for some recommendations on how that can most easily be accomplished with the ...
86
votes
4answers
27k views

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

I've been seeing a lot of references of Dependency Injection (DI) & Inversion Of Control (IOC), but I don't really know if there is a difference between them or not. I would like to start using ...