Aug
19

Dependency Injection – Keep your privates to yourself

Author Eli Lopian    Category .NET Tests, TDD     Tags

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

Bookmark and Share

442 Comments to “Dependency Injection – Keep your privates to yourself”

  • De Budapeste para Viena July 23, 2016 at 7:03 am

    I read this piece of writing completely on the topic of the resemblance
    of most recent and previous technologies, it’s amazing article.

  • 192.168.1.1 login July 23, 2016 at 8:51 pm

    You really make it appear so easy together with your presentation however I in finding this matter to be really something which I feel I would by no means understand.
    It seems too complicated and very wide for me. I’m taking a look ahead to your subsequent post,
    I will attempt to get the cling of it!

  • http://Groupspaces.com July 25, 2016 at 4:30 pm

    If you’re unfamiliar with digital marketing and seo , we will provide a cohesive
    define of the process, time framjes and statistics designs to draw (http://Groupspaces.com) show increasing results together with making certain that your whole
    requests andd wishes are met.

  • laser therapies July 26, 2016 at 4:00 pm

    Great goods from you, man. I have take not your stuff
    previous to and you’re just too great. I actually like what you have receioved right here, really like what you’re stating
    and the way in which in which you assert it. You are making it
    entertaining and you still take care of to keep it
    wise. I cant wait to learn much more from you.
    That is really a terrific site.

  • vihowowu.bandcamp.Com July 26, 2016 at 8:25 pm

    For example, I inspired one despondent consumer, with a very tight adveertising finances, to get together
    together with his fellow retailers in a neighborhood mall to dischss the possibility
    of launching a marketing budget template 2015 (vihowowu.bandcamp.Com) marketing campoaign that they
    might all profit from with tthe additional good thing
    abouit with the ability to shnare the whole cost.

  • http://projects.adityainfo.co.in/ July 27, 2016 at 4:37 am

    The fact is: Regardless of a full-sized sport utility vehicle CUV comes in and of your financial consideration. The main benefit of
    an individual or the company is already being snapped up in the
    Florida lemon law. You should be based on a specific customer in mind that automobile new most anticipated cars of 2017 (http://projects.adityainfo.co.in/) it tends
    to look at. Side and curtain airbags are now normal across the Pajero variety, combining stability control, grip
    control, power, seating capacity etc. It is necessary to have the standard
    features.

  • online marketing July 30, 2016 at 9:35 am

    Hello to every , as I am genuinely eager of reading this blog’s post to be updated daily.
    It consists of pleasant material.

  • http://tweetsontits.com/index.php/k2/item-single July 31, 2016 at 5:29 pm

    It also can be used as a anti snatch personal alarm that when a purse is taken from a woman a pin is
    pulled out and the alarm sounds loudly and a light flashes startling the intruder who normally would drop the device and purse rather than rather than to call attention to himself.
    No worries though, as you are still able to get the tax credit.
    pepper sprays could be used in the same way and located in different areas of the home for the same protection purpose.

  • travel the world for free August 2, 2016 at 4:49 am

    Thanks for finally talking about > Dependency Injection – Keep your privates to yourself «
    Development and Integrity Management by Eli Lopian < Liked it!

  • Christie August 2, 2016 at 9:16 pm

    Each phrase, preferably containing two to three optimizers words, how to search about various topics.
    suchmaschinenoptimierung google kostenlos – Christie – has a solid approach into
    what is needed closer to his visions.

  • clenches August 4, 2016 at 12:56 am

    Excellent way of describing, and fastidious article
    to get facts about my presentation subject, which i am going to present
    in academy.

  • best poker on the internet August 5, 2016 at 11:19 am

    Canada also has a number of unique options available
    to its residents and expat poker participant populations.

  • công ty cung cấp hoa quả sấy xuất khẩu August 7, 2016 at 12:26 am

    What’s up to every body, it’s my first visit of this weblog; this
    blog carries awesome and in fact fine information in support of readers.

  • selye h stress and disease August 7, 2016 at 8:15 am

    Just make sure you have the time to enjoy your bath – without creating a pressure situation.

  • online business banking santander August 9, 2016 at 2:55 am

    This service gives detailed suggestions (at batch, instruction and transaction level) on thhe standding of a Business
    online business banking santander instruction after processing has completed.

  • יש לו נקודה טובה August 9, 2016 at 10:25 pm

    Bramah manufactures locks for domestic and commercial
    use. In addition, you might need to have an electronic key replaced and a locksmith can also perform this service.
    In certain emergency situations, the availability of an expert locksmith in Delta
    BC is really helpful for the users.

    My web blog יש לו נקודה טובה

  • piranha attack video August 10, 2016 at 5:52 am

    It seems even the jaws of the most formidable predator of the Late Cretaceous
    - Tyrannosaurus rex may not have been a match for these freshwater
    predators. Black Piranha and Extinct Relative Had Strongest
    Bites of All. They also eat land animals that
    venture into their native habitat.

  • Kaspersky discounts 2016 August 11, 2016 at 8:36 am

    I have read so many articles about the blogger lovers
    except this piece of writing is truly a fastidious paragraph, keep it up.

  • https://padonharvard.wordpress.com/ August 11, 2016 at 10:54 am

    This will be invaluable if you encounter any difficulties at
    a later date over money issues. If you are unable to see the property a second or third time
    you still have ways of ensuring you’re not walking into a lemon. But isolation is not healthy over long periods of time.

  • foxe.pl August 12, 2016 at 3:22 pm

    Wе absⲟlutely love your bloɡ and find most of your post’s
    to ƅe just what I’m looking for. Dooes one ߋffer gueѕt
    wrіters to wriute content to suit yоur needs?
    I wouⅼdn’t mind creatiing a post or elaborating оn a
    lоt of thhe subjеϲts you write in relation to here.
    Again, awesome blog!

  • Thảo dược kích thích mọc râu hàng đầu từ Mỹ August 13, 2016 at 5:39 am

    Tác hại tiềm ẩn của tia cực tím khi nhìn dưới ống kính
    UV. Những chấm đen đó là những phần da bị tàn phá mà không
    thể thấy bằng mắt thường.

  • residential and commercial cleaning August 15, 2016 at 8:16 pm

    Hiya very nice website!! Man .. Beautiful ..

    Wonderful .. I’ll bookmark your site residential and commercial cleaning take the feeds also?
    I am happy to search out so many useful information here in the post, we want work out more techniques in this regard,
    thank you for sharing. . . . . .

  • vr headset August 18, 2016 at 3:04 am

    A increased-finish mannequin of the headset will eschew a smartphone in favor of a
    built-in show and be tethered to a excessive-powered laptop or desktop
    PC.

  • sarung hp samsung August 21, 2016 at 5:02 pm

    Hey there just wanted to give you a quick heads up. The text
    in your post seem to be not viewable on the screen in Chrome.

    I’m not sure if this is a format issue or something to do with browser
    compatibility but I thought I’d post to let you know. The design and style look great though!
    Hope you get the issue solved soon. Kudos

  • http://www.simonacane.com/discoveryappennino/ August 22, 2016 at 3:09 pm

    One of many ways that are finest to find out about best forex brokers in the us
    [http://www.simonacane.com/discoveryappennino/] foreign exchange market is to start a trading emini demo account.

  • struggle August 22, 2016 at 6:16 pm

    The supply price, or the request price, could be the price of which your brokerage will promote foundation currency as
    a swap for quote currency.

    my web site struggle

  • Paul Ponna newsletter August 22, 2016 at 11:45 pm

    Setup Activate Profit is going to be released next month by
    Paul Ponna and Jeff Clark.

  • infection August 23, 2016 at 11:25 am

    Thiss is most common for uncircumcised males to have this
    problem.Some breedrs maybe prone tto cerrtain eye problems compared to others, so it.
    The purpose and layout of the Yeast Infection No
    More guide is clear and concise, making it good for printing or reading at your computer.

  • pendant lighting shades lowes August 24, 2016 at 1:47 am

    More importantly, it’s beautiful and with the 3 light pendant over the
    dining table makes a pleasant statement.

  • ارخص شركة نقل اثاث بالدمام August 25, 2016 at 3:14 am

    This article is intended as only a brief summary of Stark
    II Phase II. It does not cover every aspect of the regulations.

  • קורס מנעולן פתח תקווה August 25, 2016 at 9:05 pm

    Since then, the design of locks has advanced and incorporated new materials, such as steel, plastic, and other synthetic materials.
    ‘ Locksmiths can also give genuine suggestions on the kind of security systems which should be installed.
    Are you looking for an effective way to protect your
    family and your home.

    my blog – קורס מנעולן פתח תקווה

  • signal Decoding August 26, 2016 at 10:16 pm

    If you decide to buy a computer that will better suit your needs, be sure to choose one that will work seamlessly with the software you want.

  • Parfum Cewek August 27, 2016 at 2:34 am

    I got this web site from my friend who told me about this web page and now this time I am visiting this website and reading very informative posts at this place.

  • レーザー脱毛 銀座 August 27, 2016 at 5:28 am

    私が おすすめする 銀座のレーザー脱毛サロンはこちらとなります。

  • Trinidad August 27, 2016 at 5:32 am

    Similarly its efficacy in decreasing herpes reoccurrences throughout pregnancy has actually been documented4.

  • pokemon hacks August 27, 2016 at 9:20 am

    The battle method involves catching all legendary Pokemon just like you would any
    other Pokemon: weaken it in battle, inflict it with a status like sleep
    or paralysis, and throw Poke Balls and hope for the best.

    Additional areas of the body where the youngsters like to put on tattoos tend
    to be: the arms for bracelets tattoos, over the ankle tattoos, neck tattoos,
    lower forearms tattoos, over the eye brows tattoos, and many other spots as anyone can think about.

    A woman will tell you a story, then these Pokemon will roam around Unova.

  • CONTOURING August 27, 2016 at 12:59 pm

    Marvelous, what a blog it is! This website provides valuable information to
    us, keep it up.

  • ジニエブラ August 27, 2016 at 3:30 pm

    保湿性がアップした新機能ブラです。バストを適切に保ちます

  • Thuốc tăng cường sinh lực giúp cánh mày râu “ân ái” nhiều hơn August 28, 2016 at 12:33 am

    Các biện pháp khắc phục điển hình thường là
    thay đổi lối sống, cùng với bổ sung testosterone (nếu
    có chỉ định của bác sĩ).

  • iphone ios 6 newsstand August 28, 2016 at 8:45 pm

    Enjoy wealthy interactive features, like full-display screen video and a mobile-friendly interactive radar, all from the skilled
    local news group you trust.

  • complement alimentaire August 28, 2016 at 9:44 pm

    Les fameuses calories vides des produits raffinés remplacent les produits naturels
    et wealth nutritionnellement.

  • Automotive Blog August 29, 2016 at 5:23 pm

    Great post! We will be linking to this particularly great article on our website.
    Keep up the great writing.

Post comment