[LRUG] Dependency Injection and DHH
Stephen Henderson
stephen at cognitivematch.com
Wed Apr 30 07:12:28 PDT 2014
DHH has done a blog post which explains a bit better his argument that TDD/DI can make code worse: http://david.heinemeierhansson.com/2014/test-induced-design-damage.html
It makes a lot more sense now and it’s a very rails-specific argument. The gist of it is:
* The ports-and-adapters model of decoupling business logic from frameworks doesn’t work well with Rails controllers.
* It requires too many extra objects and classes which end up obscuring the original intent, e.g.turning a 5 line controller method into a handful of business objects and callbacks.
* There’s little point in trying to unit test controllers directly. You should only test controllers at integration level and above.
I can see where he’s coming from and I sort-of agree to a point. It’s definitely worth watching the Jim Weirich presentation he talks about to put it in context (https://www.youtube.com/watch?v=tg5RFeSfBM4).
The tight coupling of framework with business logic and persistence is arguably a big reason why people like Rails. If you completely decouple your business logic from the framework are you losing a lot of what makes Rails so attractive? Personally I’m not a massive fan of Rails because of tight coupling so I’m probably not a good person to answer that, but it’s an interesting question. I think some of it is definitely linked to the scale of the application in question, but that’s a general Rails problem too :-/
Stephen
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?
Fox
--
"What does the @sleepyfox say?"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20140430/f4a012f3/attachment-0003.html>
More information about the Chat
mailing list