[LRUG] Dependency Injection and DHH

Sasha Gerrand chat-lists.lrug.org at sgerrand.com
Wed Apr 30 08:39:21 PDT 2014


On 30 April 2014 15:12, Stephen Henderson <stephen at cognitivematch.com>wrote:

> 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 :-/
>

If you haven't already, I'd also recommend reading Bob
Martin<http://en.wikipedia.org/wiki/Robert_Cecil_Martin>'s
response to the DHH blog post:
http://blog.8thlight.com/uncle-bob/2014/04/25/MonogamousTDD.html
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20140430/05ca0a12/attachment-0003.html>


More information about the Chat mailing list