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

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

  • delhi university April 1, 2016 at 11:34 am

    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!

  • Ines April 4, 2016 at 2:24 am

    ‘Are people really searching online for my product or services’.

    The usual SEO methods include keyword research, link building
    and such. Thematic relevance is of key importance for the
    creation of quality backlinks. Further the sites whose ranking using the search engines is good will attract potential clients, which results
    to mores sales.

    My site Ines

  • bramotsavam mp3 songs April 4, 2016 at 5:14 am

    I go to see each day a few blogs and sites to read posts, but this
    blog offers quality based content.

  • Www.Etlaaq.Com April 4, 2016 at 9:20 am

    Hello, after reading this remarkable post i am as well
    glad to share my know-how here with mates.

  • Asuransi Pendidikan Terbaik April 4, 2016 at 2:30 pm

    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!

  • April 4, 2016 at 4:27 pm

    The story development during the game is minimal, but the plot is solid.
    Clos a single end with wooden for the roost, and clos the remaining sides with wire.
    Although occasionally a mite frustrating, Hoggy’s a great-looking, fun and innovative freebie.

  • game online April 5, 2016 at 8:42 am

    To watch the NBA All-Star Game live streaming online for free, anyone in the U.
    Bike games are the effective way to introduce the child to bike and bicycling ideas.
    However one must tread with caution as they may be sucked into gambling with this very innocent of a game, and one must take
    not to pay up so much that one cannot meet their daily family
    expenses due to their gambling debts.

  • bqdhaikjd April 7, 2016 at 8:18 am

    But, perhaps for the first time this season, the Detroit Red Wings appear settled on line combination they hope will remain intact for a while. It helps when you’re 3-0-1 in the past four games and averaging three goals per game during that stretch. louis vuitton outlet online In the 1950s, he said, federal courts ruled that the NAACP did not have to disclose its membership lists because its members might be subject to threats or worse forms of illegal activity. s ray ban sunglasses
    senator from Vermont He did not take that well,” Marks explained.
    USA Veterans Affairs to Samantha Aldrich, 88 Greenwich Road, $100,000. michael kors outlet Corissa, who is an officer of the Hollister Future Farmers of America chapter, counts Aalgaard as one of her close friends. v
    “I keep a note of everything I eat on my phone and look it up on a calorie counter,” she said. cheap air jordans The family owned restaurant also offers 13 other margaritas, including the Corazon — a mixture of peach liqueur, sweet and sour, and a splash of Chambord.
    x 145. Cincinnati, Ian Kahaloa, RHP, Campbell HS, Ewa Beach, Hawaii. michael kors outlet online Then Wednesday had one of her best games, shaking off a slow start to score 26 points with 10 rebounds and 9 assists for the Red Wolves, who shot 48. coach handbags
    The Islanders will play its five remaining home games at Lancaster’s Clipper Magazine Stadium michael kors outlet Scroggins began his career at USC, but transferred to El Camino College in California for his sophomore campaign.
    Christopher Plewa to Rosa I. Torres, 73 Talmadge Drive, $146,500. coach outlet Jang captured her maiden LPGA title at the Coates Golf Championship in Florida last month and has quickly made it two. o michael kors handbags
    Sources in the inspector general office tell me they see the requests and accusations as an attempt to intimidate them and deter them from continuing Clinton-related work coach factory The basic scratch tests used to discover allergy triggers usually yield positive results for 45 percent of the tested triggers, he said.
    Abbas expressed his condolences over Force’s death, according to the official Palestinian news agency WAFA, and said the establishment of a Palestinian state was key to ending the violence. louis vuitton handbags Once there’s a market, more will participate, he said.
    The extra 10 percent, taken from the local primary property tax, allows the district to make up for budget cuts in state aid, which funds two-thirds of the district’s budget. michael kors outlet online Her blog about last week:em?!–gte mso 9]xml o:DocumentProperties o:TemplateNormalo:Template o:Revision0o:Revision o:TotalTime0o:TotalTime o:Pages1o:Pages o:Words200o:Words o:Characters1143o:Characters o:Lines9o:Lines o:Paragraphs2o:Paragraphs o:CharactersWithSpaces1403o:CharactersWithSpaces o:Version11.
    Del Piero, who were the original owners of Rancho Larios, sat on the State Water Board. michael kors bags She had kept him apprised of Inez’s activities before that, likely picking up on the fact that he was interested, and she talked him up to Inez every chance she got.
    a Gotcha coach ???????? — DeAngelo Williams (@DeAngeloRB) Antonio Brown’s hype dance louis vuitton handbags Garrison, a baritone, won his first Grammy Award in 2009, also with The Phoenix Chorale, for “Best Small Ensemble Performance,” awarded for the album “Spotless Rose: Hymns to the Virgin Mary,” which was recorded in his first season with the chorale in 2005.
    By focusing on these original characters, Doc Con explores and educates those fans that were not fortunate enough to have discovered that human ingenuity and honor are just as valuable an asset during adversity as strengths bestowed supernaturally. Saturday, June 13Where: Desert Botanical Garden, 1201 N. v coach handbags
    A sharp contrast to the gunfire that echoed in this building Monday night Put more real farms on that Class 1 Panoche soil, please, and not government subsidized solar projects.
    b Shaelynn Cowles, Churchill, senior michael kors handbags The Zags flew from Dallas to Tulsa and bused into town Monday for the series, which is coming during their spring break. w
    In January, the Justice Department sued it over the emissions-cheating software found in hundreds of thousands of vehicles sold in the United States, potentially exposing VW to billions of dollars in penalties for clean air violations With the help of specially-place stones that absorb the heat from the sun and radiate warmth in the evenings, it’s actually very easy. nfl jerseys
    “I think she has helped people on our team start to think, ‘OK, what might be possible?’” Solof said. “Instead of thinking, ‘OK, 16:40 is really good,’ maybe you should think about 16-flat, or 15:40.” louis vuitton outlet online Turkey is under pressure to reduce the number of migrants crossing into Greece ahead of Monday’s summit meeting of Turkey and the EU leaders. n michael kors outlet online
    It seems more likely that the mechanism is automatic percentage increases that continue to propagate the discrepancy by definition michael kors outlet 4, 6 and 7 to fall out of contention and close with a 75 to tie for 20th.
    Gail J. Laflamm to Michael F. Lafreniere and Tanya Severance, 41 South St., $148,000 louis vuitton handbags “While Beth’s tenure as president has tragically been cut short, her efforts over the last eight months have set the university on a path toward continued excellence,” said Robert Harrison, chairman of the Cornell board of trustees. x oakley sunglasses
    His team is convinced they must dispatch with Cruz before turning their full attention to taking down Trump Dial was unable to tell reporters his unit, or the name of his commander.

  • Canvas paint Startonight April 7, 2016 at 8:19 am

    I went fоr a ᥙniqᥙе ǥіft and fⲟսnd tɦіs pогtгаy
    tɦat lіɡһting insіɗᥱ οf tɦe ɗaгкiѕҺ.

    Ιtѕ ѕоmᥱкіnd of dοual-νіᥱѡ рогtгaʏ.
    Ӏ сan lоoк at
    it thгoսgһ
    tɦе ⅾaу, ѕtіll WҺіⅼе іѕ ⅾaгκ ѡіtҺіn ϳᥙѕt thе hоusе, tҺе
    ρoгtrɑу іѕ continue
    tο aⲣpaгеnt.

    Ιs thіѕ sοme foгm ߋf aⅼіеn tеcҺnoloցy/
    oг іѕ jᥙst sοmе еⲭcерtіоnal աall ɑrt?

    Hοԝеѵег, і ⅾеtᥱrmіneԀ іn Ԁіrectiⲟn ⲟf оƅtaіn іt ɑѕ a
    геwarɗ, neνегtҺᥱlеѕѕ tοwагɗѕ оrԁег ѕοme fⲟr mүsеⅼf aѕ wᥱlⅼ :) .

    I fееl that ԝіtҺіn maҝᥱ any ɗіffeгеncе оf ǥіftѕ, tҺіѕ ѡߋսⅼԀ
    Ьe tɦе majοr.
    ᗪо οn үоսг օաn aρрeaг tⲟ
    bе tҺе іdеntіcɑⅼ?

  • April 7, 2016 at 8:30 am

    Hello, i think that i saw you visited my blog thus i came to “return the
    favor”.I am trying to find things to enhance my web site!I suppose its ok to use
    a few of your ideas!!

  • derek April 7, 2016 at 12:24 pm

    I don’t even know the way I ended up right here, but I
    assumed this post used to be good. I don’t realize who you are but certainly you are going to a well-known blogger when you are not already.


  • April 8, 2016 at 9:38 am

    The FDNY Mobile CPR Unit will host bystander CPR Education sessions at your place for groups of 15 or extra.

  • April 9, 2016 at 1:03 am

    When a large department breaks off the primary tree and gets lodged within the different branches or if a big crack is discovered,
    the tree needs to be eliminated.

  • April 9, 2016 at 4:03 am

    It’s also important to do your homework when in search of a tree service as
    a result of any mishaps may have devastating results to your private home or the remainder of the

  • April 9, 2016 at 8:38 pm

    Having read this I believed it was really informative.
    I appreciate you spending some time and effort to put this short article together.
    I once again find myself personally spending a significant amount of time both reading
    and leaving comments. But so what, it was still worth it!

  • video chat April 11, 2016 at 10:16 pm

    Ragazzi che ne dite di questa video chat?

    come vi sembra?
    Fatemi sapere!!! E’ senza registrazione e gratis

  • April 12, 2016 at 5:02 am

    Wonderful goods from you, man. I have bear in mind your stuff previous to and you’re simply extremely wonderful.
    I really like what you have got right here, certainly like what you’re stating
    and the way in which you are saying it. You’re making it enjoyable and you still care for to keep
    it smart. I can’t wait to learn much more from you.

    That is really a wonderful web site.

  • weight loss tips April 18, 2016 at 5:05 pm

    Right here is the rigt website for everyone who hopes to understand this topic.
    You unxerstand a whole lot its almost hard to
    argue with yoou (not that I personally woulld want to…HaHa).
    You definitely put a brand new spin on a subject thhat
    has been discussed for a long time. Excellent stuff, just great!

    Feell free to surf to my homepage – weight loss tips

  • Christal April 19, 2016 at 10:10 pm

    Facebbook promoting will be effective in some industries aand allows focusing on primarily
    baserd oon demographic information akin to Age,
    Gender, Education Level, and Marital Status.

    my pzge :: WPGateway Secure Review (Christal)

  • hosting site April 23, 2016 at 8:16 am

    Excellent website you have here but I was wanting
    to know if you knew of any forums that cover the same topics talked about here?
    I’d really love to be a part of group where I can get opinions from other knowledgeable individuals that share
    the same interest. If you have any suggestions, please let me know.
    Appreciate it!

  • Berenice April 27, 2016 at 2:11 pm

    One of the negative effects of the Affordable Care Act
    is that it’s compeling the medical community to come to be
    much more effective, which’s a good thing for medical realty investment company.

    Here is my web-site real estate appraiser casper
    wy (Berenice)

  • Peluang Bisnis May 11, 2016 at 6:12 am

    Right here is the rigt website for everyone who hopes to understand this topic.
    You unxerstand a whole lot its almost hard to
    argue with yoou

  • May 13, 2016 at 2:56 am

    Thhe Greatest Bang for Your Buckk electric nail gun lowes ( gun is not one gun, it’s 4: the Freeman P4FRFNCB Framing/Ending Combo Package.

  • Jerri May 15, 2016 at 4:02 pm

    Hello, I wish for to subscribe for this web site to obtain hottest updates, therefore
    where can i do it please help.

  • grosfillex chaise May 21, 2016 at 8:22 pm

    These physical bodies will be grosfillex plastic chairs rattling utile and suitable
    out of doors piece of furniture.

  • May 22, 2016 at 12:12 pm

    You nee tߋ be a рart ⲟf а contest for one oof thе reatest
    sites online. Ⅰ’m goіng to highly recommend this site!

    my wweb ρage … B2Bemail lists (

  • June 1, 2016 at 6:40 pm

    I like this post, enjoyed this one thanks for posting.

  • Madden Mobile Hack June 3, 2016 at 5:09 am

    It’s a shame you don’t have a donate button! I’d most certainly donate to this superb
    blog! I suppose for now i’ll settle for bookmarking
    and adding your RSS feed to my Google account. I look forward to new
    updates and will talk about this site with my Facebook group.
    Talk soon!

  • Paint With Gunpowder June 4, 2016 at 8:03 pm

    An impressive share! I have just forwarded this onto a coworker who was conducting a little research on this.

    And he actually bought me dinner because I discovered it for him…
    lol. So let me reword this…. Thanks for the meal!!
    But yeah, thanks for spending the time to talk about this matter here on your site.

  • June 4, 2016 at 8:10 pm

    Great post. I used to be checking continuously this blog and
    I’m impressed! Extremely useful info specially the remaining phase :
    ) I deal with such info a lot. I was seeking this certain info
    for a very long time. Thanks and best of luck.

  • Reebok Shoes Sale June 4, 2016 at 8:20 pm

    Tremendous things here. I’m very glad to look your post.
    Thank you a lot and I’m having a look ahead to contact you.
    Will you kindly drop me a mail?

  • acheter babycook occasion June 5, 2016 at 9:14 am

    Babycook pasta rice cooker solo et duo – sur allobebe –
    de cuisson pour surveil to les feculents rapide
    sans, compatible avec solo Cdiscount guide vous de des markets sur votre
    applications bebe Babycook unique de BEABA + Discover comme pour vos achats Puericulture & Eveil bebe…!

  • Addiction To Marijuana June 5, 2016 at 1:03 pm

    Marijuana Detox Tips – How to Handle Uncomfortable Symptoms

  • Facebook Ads Account Rep June 5, 2016 at 5:10 pm

    If you might be in operation for example a restaurant, that’s offered
    to the individuals on everyday, it is a whole lot
    easier to promote you sms as you’re able past it on doors and windows or walls for fast visibility to individuals.
    You must have 5,000 fans or even more before you decide to really start purchasing marketing.
    After adding your own campaign, complete the task by choosing the
    sort of bid you’re going to take.

  • Madden 17 Connected Franchise June 8, 2016 at 8:42 am

    Excellent blog here! Additionally your web site a lot up fast!
    What host are you using? Can I am getting your affiliate link in your host?
    I desire my website loaded up as fast as yours lol

  • belcaro denver real estate June 9, 2016 at 12:58 am

    It would only take about 25min just to get to the intersection in Downtown Evergreen which is
    from the Clear Creek County section of Evergreen in the Brook Forest Estates
    community. The housing boom is fueling a seller’s market that is pushing
    prices up to levels never seen before on a non-coastal city.
    The lack of inventory in the low and middle range of the market drove the average home prices up 8.

  • thuê xe 29 chỗ June 9, 2016 at 3:09 am

    Do you mind if I quote a few of your posts as long as I provide credit and sources back to your weblog?
    My blog site is in the exact same area of interest as yours and my visitors would definitely benefit from a lot of the information you provide here.

    Please let me know if this alright with you. Thanks a lot!

  • จ้าง Netidol รีวิวสินค้า June 10, 2016 at 5:47 am

    magnificent points altogether, you just won a brand new reader.
    What might you suggest in regards to your publish that you just made a few days
    in the past? Any sure?

  • Lenora June 11, 2016 at 11:20 am

    I read this post completely regarding the difference of latest and previous technologies, it’s remarkable

  • June 22, 2016 at 2:36 pm

    Other elements of the Freestyle(R) are the LCD screen, digital display, memory button and attractive tote bag.

    The First Years Company has successfully developed breast
    pumps that can be used manually or with the use
    of batteries. They are also more durable and come with a 3 to 5 year
    warranty, compared to a 1-year warranty for the personal pumps.

  • migliori aspirapolvere miele June 24, 2016 at 11:44 pm

    Heya! I’m at work browsing your blog from my new iphone 3gs!
    Just wanted to say I love reading through your blog and look forward to all your posts!
    Carry on the fantastic work!

Post comment