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

371 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!

  • www.biggerplate.com 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 http://www.louisvuittonhandbagsrack.us.com 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 http://www.raybansunglassesbuy.co.uk
    “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. http://www.coachhandbags.com.co
    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. http://www.michaelkorsoutletbuy.us.com Saturday, June 13Where: Desert Botanical Garden, 1201 N. v coach handbags
    A sharp contrast to the gunfire that echoed in this building Monday night http://www.michaelkors.us.org 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 http://www.michaelkorshandbagsup.us.com 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 http://www.cheapmichaelkorsbags.us.com 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ɑⅼ?

    http://www.amazon.com/gp/product/B01B181BMK/?tag=olarian-20

  • http://wdjstech.com/ 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.

    Cheers!

  • http://arquiblog.uniandes.edu.co/blogs/arqu3505/2010/05/13/art615-a-pavilion-by-aalborg-university-students/ 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.

  • http://youtube.com/watch?feature=share&v=o7oBV4XpkTk 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.

  • https://www.youtube.com/watch?feature=kp&v=o7oBV4XpkTk 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
    yard.

  • urlshrimp.com 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

  • vacavilleicesport.com 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)

Post comment