[LRUG] Hexagonal Architecture Guidelines For Rails

Luke Morton lukemorton.dev at gmail.com
Tue Mar 18 04:49:46 PDT 2014


I don't use HN enough to remember my login so afraid I can't comment there.

Some people like to fallback to DHH's advice whenever someone suggests the
non-rails way inside of rails. Arguments like "you might as well not use
rails" and "reimplementing Java in Ruby" aren't really helpful and miss
some of the simple benefits a better design can have.

Here on this list just the other day someone complained about slow tests
and everyone suggested starting with rails. That's a huge code smell to me.

Your advice regarding "domain objects have no knowledge of persistence" is
a great one for speeding up tests. I would even suggest you go further and
write your domain logic in a rails-less environment. Not just because it's
"good design" but because you don't want to be booting rails when you
should be focusing on the domain.

Of course you will want to test your queries against a DB but that's the
persistence layer and is a small subsection of your entire application and
that arguably still doesn't need rails booted!

Also another side effect of not requiring rails in your tests is that you
get tidier tests. It's much easier to mock out dependency injected logic
rather than just assuming the object exists in rails application time and
then monkey patching unrelated objects at test time with spies.

Good design isn't just for the sake of it. If you are doing TDD it is a
cheap way of getting fast and easy to read tests.

Luke

On 18 March 2014 11:15, Stephen Best <bestie at gmail.com> wrote:

> I have a blog post that is currently enjoying a fleeting moment of
> exposure via a questionable "news" for "hackers" outlet. Would love to hear
> LRUG's feedback.
>
> https://news.ycombinator.com/item?id=7421018
>
>
> Stephen Best
>
> theaudaciouscodeexpiment.com
> github.com/bestie
> @thebestie
>
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20140318/c54712ed/attachment-0003.html>


More information about the Chat mailing list