473,378 Members | 1,617 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

What is Dependency Injection?

Pigsaw said...
"You don't want to hard code dependencies into your classes, because
then you can't test them without relying on the dependent classes. So
you "inject" those dependencies simply by setting them as properties -
possibly in the constructor, possibly with setter methods. And it
becomes all the easier if you have a little container which manages
how to configure those dependencies (properties) before they're
injected (set). "

Any shorter one?

Oct 14 '07 #1
2 1404
Dependency injection is creating a wrapper around classes that your class
depends on.

You can than build stand-alone test cases that no longer "depend" on other
classes.
"Anonieko" <an******@hotmail.comwrote in message
news:11**********************@t8g2000prg.googlegro ups.com...
Pigsaw said...
"You don't want to hard code dependencies into your classes, because
then you can't test them without relying on the dependent classes. So
you "inject" those dependencies simply by setting them as properties -
possibly in the constructor, possibly with setter methods. And it
becomes all the easier if you have a little container which manages
how to configure those dependencies (properties) before they're
injected (set). "

Any shorter one?

Oct 14 '07 #2
Hello Anonieko,

read there http://www.martinfowler.com/articles/injection.html
---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
APigsaw said...
A>
A"You don't want to hard code dependencies into your classes, because
Athen you can't test them without relying on the dependent classes. So
Ayou "inject" those dependencies simply by setting them as properties
A- possibly in the constructor, possibly with setter methods. And it
Abecomes all the easier if you have a little container which manages
Ahow to configure those dependencies (properties) before they're
Ainjected (set). "
A>
AAny shorter one?
A>
Oct 14 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
11
by: Bã§TãRÐ | last post by:
I have been working on this particular project for a little over 2 weeks now. This product contains between 700-900 stored procedures to handle just about all you can imagine within the product. I...
3
by: DJTN | last post by:
I'm getting the following error when I try to compile my setup project in VS 2002. I have re-installed the .net framework 1.1 and it didnt solve the problem. WARNING: Unable to find dependency...
10
by: bregent | last post by:
I've seen plenty of articles and utilities for preventing form injections for ASP.NET, but not too much for classic ASP. Are there any good input validation scripts that you use to avoid form...
8
by: stirrell | last post by:
Hello, One problem that I had been having is stopping email injections on contact forms. I did some research, read up on it and felt like I had created a working solution. I hadn't gotten any...
5
by: Michael Feathers | last post by:
Why aren't there many libraries for Dependency Injection in C++. It's been a very useful pattern in the Java community, but I run into many teams that could use it in C++, but it never occurs to...
7
by: | last post by:
There are assorted "SQL Injection vulnerability assessment tools" out there. They scan your site and send your report. They also take your money. We don't have the money so I was wondering if I...
3
by: Danno | last post by:
Just that simple question....out of curiosity.
3
by: -Lost | last post by:
Runtime dependency loading, worth the trouble? I've been researching methods of "dynamically" loading and unloading dependencies at runtime (trying my best to think of a nice solution of loading...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.