Dependency Injection – Keep your privates to yourself

Jacob Proffitt has hit the nail on the head with his “I do wish that people would admit that DI doesn’t have compelling applicability outside of Unit Testing” post, the discussion continues with Nate Kohari response post and Jacobs counter post. Oren has also joined in with two posts.

Here a some ideas for you to think about.

DI as a Silver Bullet – You lose power

When you use DI as a ‘Silver Bullet’ you are losing more then half the abilities of your programming language. You can not use static methods or the ‘new‘ keyword or sealed types. Oh, you have to make all your methods virtual too. This is going to be even harder once Extension Methods (and Linq) become main stream.

Code to Enable Change – Costs More

Creating Code that is there only to “Enable Change” has a big “YAGNI” written all over it. (Making the code more complex and thus wasting time in development and then in maintenance, for a chance that it will be used in the future). We have understood that this is the wrong plan ages ago. We now know that we can not predict the future and it is best to change our code only when we need to (a process called refactoring).

Keep your Privates to Yourself

Jacob, you are quite right about DI coming into fashion only because the tools where not good enough. DI does have other applications outside testing, but it is being overused in most application only to make the code testable.

One of the first issues that was discussed when TDD was starting was: “should we change our code to make it testable?”
Should we change the visibility of our code?
Should we change the design of our code?
This lead to a collision between testable code and OO encapsulation. Developers started to expose private parts of the code to enable testing. It started with private fields and methods and now it is the complete design. This collision still exists when using inadequate tools, but with the right tools, you can enjoy the best of both worlds.

Get the Best Tools to get the Job Done

Thousands of developers have understood this and have started testing there code without being forced to use a specific pattern required by some tools. Many development shops, didn’t test their code because of the testability/design collision. With the right tools they now understand and test their code.

As Joel Says: “Get the best tools

417 comments
  1. Múltiples son los comentarios positivos sobre este reservado local que la chef Monica Patiño tiene en la colonia Roma, y es que
    si eres entusiasta del pan recién horneado y la mermelada orgánica (entre otros muchos productos) este es el sitio idóneo para ti.
    Aquí se venden productos al peso, quesos, botanas árabes y repostería fresca del día.

  2. Greate pieces. Keep writing such kind of information on your site.

    Im really impressed by it.
    Hi there, You’ve performed an excellent job.
    I will definitely digg it and in my opinion recommend to my friends.
    I am confident they will be benefited from this website.

  3. Description_450 Folks have responded positively to this call by considering of other indicates to supplement the use of wood
    in furniture gadgets.

  4. Morgan announced a strategic partnership աith On – Deck Capital, аn alternative lending company, tto
    originate, underwrite, andd distribute loans tһat aree targted ѕpecifically ɑt ѕmall businesses.
    When people try tο absorb too much information аll at οnce, their brains caan become overwhelmed.
    When thee redo wwas completed, Jon mеt tһе staff οutside
    tо unveil thᥱ neᴡ namе,
    ɑnd іt աaѕ now Pacific Coast Wine
    Bar аnd іnside tҺе wine
    displlay wass breathtaking.

    Αlso visit mʏ Һomepage
    rc helicopter hd camera

  5. Most people set impossible targets for themselves when the New
    Year comes round like wanting to lose weight,
    quit smoking, get fit or whatever it is they want. How often have
    you wondered whether you could possibly increase your penis size.
    Growing your penis bigger is absolutely possible, and depending on how
    you go about doing so, is quite easily achievable too.

  6. Thank you for the good writeup. It in fact used to be a leisure account it.
    Look complex to more brought agreeable from you!
    By the way, how could we communicate?

  7. Workers back then had much better pay and could afford a high standard
    of living that included buying a family home, saving for
    retirement, investing on the stock market and even owning a
    family car or two. If a company is considering such a program, it doesn.
    One of those things about marketing research is you have a lot of things in hand that ought to
    be studied with a great deal of concentration.

  8. I think what you posted was actually very logical.
    But, think on this, suppose you were to create a awesome post title?

    I ain’t suggesting your content isn’t solid., however what if you added something that
    grabbed folk’s attention? I mean Dependency Injection – Keep your
    privates to yourself « Development and Integrity Management by
    Eli Lopian is kinda vanilla. You might peek at Yahoo’s home page and note how they
    write article titles to get people to click. You might
    add a related video or a related pic or two to grab people interested about what you’ve written. Just my opinion, it could make your posts a
    little livelier.

  9. I’m now not certain where you’re getting your information, however good topic.
    I needs to spend a while finding out more or figuring out more.
    Thank you for great info I was in search of this information for my
    mission.

  10. I’m no longer sure the place you’re getting your information, however good topic.
    I must spend a while learning more or figuring out
    more. Thanks for wonderful info I used to be in search of
    this information for my mission.

  11. It’s awesome to pay a quiϲk visјt this web ρɑցe ɑnd
    rеaԀіng tһее νiеաѕ ⲟf all ϲοllеɑgueѕ ϲօncᥱгning thіs ρіеϲе οf ԝгіtіng,
    ᴡhіlᥱ Ⅰ аm alѕο ҝееn off ցеttіnjց қnoѡ-ɦοw.

    mʏ աᥱƄsіtе – ѕtⲟrm
    dгaіn cοvегѕ (Myles)

  12. I like the valuable info you supply in your articles.
    I’ll bookmark your blog and check again right here regularly.
    I am reasonably sure I’ll be told lots of new stuff right right here!
    Good luck for the next!

  13. I’m now not sure the place you are getting
    your information, however good topic. I needs to spend a while finding out much more or
    figuring out more. Thanks for excellent info I was searching for this
    info for my mission.

  14. Clash Royale is free to download and play, nevertheless, some
    sport gadgets can also be purchased for actual you do not
    need to use this characteristic, please arrange password safety for purchases in the settings
    of your Google Play Store app.

  15. obviously like your web-site but you have to test the spelling on several of your
    posts. A number of them are rife with spelling issues and I in finding it very troublesome to tell
    the truth on the other hand I’ll surely come back again.

  16. I was excited to find this site. I wanted to thank you for ones time just
    for this fantastic read!! I definitely appreciated every bit of
    it and i also have you saved as a favorite to see
    new information on your web site.

  17. We assume it is necessary that you simply learn how the search engines relate to one another.
    View our Search Engine Relationship Chart® This is a Flash
    rendering of our famous FREE PDF that is appropriate for colour printing, and all of the links are active!

  18. I believe that is among the most important information for me.
    And i am satisfied studying your article. However wanna
    statement on few common things, The site taste is great, the
    articles is in reality excellent : D. Just right job, cheers

  19. Thanks for your personal marvelous posting! I definitely enjoyed reading
    it, you happen to be a great author.I will be sure to bookmark your blog
    and will often come back very soon. I want to encourage you to ultimately continue your
    great work, have a nice afternoon!

  20. You’re so interesting! I don’t believe I’ve read through something like this before.
    So nice to discover someone with some original thoughts on this subject.
    Really.. many thanks for starting this up. This web site
    is one thing that is required on the web, someone with
    some originality!

Add Comment

Required fields are marked *. Your email address will not be published.