What is Dependency Injection?

  • Thread starter Thread starter Anonieko
  • Start date Start date
A

Anonieko

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?
 
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.
 
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


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