What is Dependency Injection?

Discussion in 'ASP .Net' started by Anonieko, Oct 14, 2007.

  1. Anonieko

    Anonieko Guest

    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?
    Anonieko, Oct 14, 2007
    #1
    1. Advertising

  2. Anonieko

    nospam Guest

    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" <> wrote in message
    news:...
    > 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?
    >
    nospam, Oct 14, 2007
    #2
    1. Advertising

  3. 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>
    Michael Nemtsev, MVP, Oct 14, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?iso-8859-1?B?bW9vcJk=?=

    How to build a dependency injection framework by myself?

    =?iso-8859-1?B?bW9vcJk=?=, Aug 24, 2006, in forum: Java
    Replies:
    4
    Views:
    376
    PerfectDayToChaseTornados
    Aug 24, 2006
  2. Michael Feathers

    Dependency Injection in C++

    Michael Feathers, Oct 11, 2006, in forum: C++
    Replies:
    5
    Views:
    7,366
    F.J.K.
    Oct 13, 2006
  3. Danno
    Replies:
    12
    Views:
    670
    Ke Jin
    Apr 10, 2008
  4. Philipp
    Replies:
    8
    Views:
    601
    Owen Jacobson
    Jun 29, 2009
  5. thomas
    Replies:
    6
    Views:
    442
    Pavel
    Sep 3, 2010
Loading...

Share This Page