[LRUG] Dependency Injection and DHH

Stephen Henderson stephen at cognitivematch.com
Mon Apr 28 06:08:31 PDT 2014

Hrrm, there’s some good points in there but he’s lumping far too many things in at once and it’s all a bit muddled.

His dependency injection argument in particular was very badly presented. His date example actually has a bug in the non-DI case which his tests won’t catch, e.g. consider this

  age = p.age
  can_drink = p.is_of_drinking_age
  puts “age=#{age}  can_drink=#{can_drink}"

If you run this around the stroke of midnight you could get “age=20 can_drink=true” depending on when each line runs. A better design would probably be to initialise the age variable on construction which would prevent having to pass the date around in the function calls too.

I think there’s a good discussion to be had around this in the general case (passing the same variable across multiple methods), but it would need a much better example to kick off from for a balanced argument.

Regarding TDD it sounds like most of his problems, particularly around coarseness of tests and how they benefit design, are what Steve Freeman covers very well in his “Test Driven Development (what’s not what we meant)” talk: http://vimeo.com/83960706  DHH's “diet book” analogy is valid but it’s not really tdd-specific and could apply to any tech buzzword. Probably a better argument is that there's often too much focus on the “how to” side of implementing tdd/agile/xp/etc rather than the “why” side of understanding the root problems they address and how they can help reduce them.

I also have a bit of an issue with his idea that you become a good programmer just by writing and reading more code. That’s definitely an aspect, but I’d say that exposure to code review from experienced developers counts for a lot more (I personally learned a lot more in my first 6 months at a company doing very strict reviews than in 2 years at another that barely did any).


From: Sleepyfox <sleepyfox at gmail.com<mailto:sleepyfox at gmail.com>>
Date: Friday, 25 April 2014 14:25
To: London Ruby Users Group <chat at lists.lrug.org<mailto:chat at lists.lrug.org>>
Subject: [LRUG] Dependency Injection and DHH

I'm wondering what those who were at RailsConf and listened to DHH's keynote - or have watched the video: http://www.justin.tv/confreaks/b/522089408 - thought about his description of dependency injection making code worse?

"What does the @sleepyfox say?"

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20140428/c749bf64/attachment-0003.html>

More information about the Chat mailing list