[LRUG] Dependency Injection and DHH
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:
> 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
response to the DHH blog post:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Chat