Skip to content
0:00 / 0:00

#hexagonalarchitecture#rubyonrails#portsandadapters

GoRuCo 2012 Hexagonal Rails by Matt Wynne

Confreaks

42K subscribers • 83 videos on Hallway • Conference channel

YouTube
  • Recommended by 1 person: 1 on Hacker News.
  • Presented by Matt Wynne
  • May be out of date. Uploaded 14 years ago, in an area where tools change fast.
  • An opinion. It argues one side of a question engineers disagree on.

Intermediate. Assumes working knowledge.

16K views14 years ago1 recommendation

Software designWeb developmentSoftware architectureDesign patternsRuby

Matt Wynne explains how to decouple domain logic from the Rails framework using a ports-and-adapters or hexagonal architecture.

In the early days of a project, Rails absolutely dazzles. Tragically, the very same forces that make it so easy to add new features to a brand new Rails application are the ones that start to hold you back as the number of features grows. Your test suite gets slower and slower, and refactoring becomes more and more of a chore. Everything seems coupled together, and it's hard to see much of a structure other than the MVC triad. In this talk, Matt explains why this happens, and shows you a way out, using a ports-and-adapters or hexagonal architecture to introduce a separation between your application's domain logic, and the Rails framework. With practical examples, you'll learn how to apply techniques like: tell-don't-ask domain services value objects view models presenters This talk is suitable for advanced Rubyists who want to enjoy the benefits of Ruby's great Object-Oriented and functional programming features in their Rails applications. Bio Matt Wynne works as an independent programmer and consultant, helping teams like yours learn to enjoy delivering software to the best of their abilities. He is a core developer on the Cucumber project, and co-author of The Cucumber Book. He blogs at mattwynne.net and tweets as @mattwynne. Help us caption & translate this video! amara.org/v/FGi4/

Why it's here

1 person recommends this

What people say. Recommended for learning how to decouple business logic from Rails to keep test suites fast and code maintainable.

jameskiltonon Hacker News • Recommends

On “Rails, callbacks, workers, and the race you never expected to lose”

Was going to say the same thing. Models should not know or care about background queues or mailings, and callback use has always caused problems for me later on. Nothing against the OP, it does explain a common edge case that many people will run into and for that it's a good article, but I wish more people would see the violations of SRP going on here and try to lead people away from this trap. I'd recommend watching link to this video (Hexagonal Rails GoRuCo talk) for one way to re-architect to get away from these inter dependencies.

kentwistleon Hacker News • Mentions

On “Slow database test fallacy”

Am I only the only one that doesn't find 'All tests in 4 minutes, all model tests in 80 seconds' very impressive? It sounds like a really long time to me. You know what could increase the speed dramatically.... decoupling. I also think decoupling phrased in the context of the Rails 2 to Rails 3 upgrade, where pretty much everything changed, makes perfect sense. Imagine just having a few wrapper classes that spoke to Rails and only having to adapt them. Sounds good to me! Bernhardt: Boundaries link Weirich: Decoupling from Rails link Wynne: Hexagonal Rails link to this video

douglasfsheareron Hacker News • Mentions

On “Rails 4.2 released”

Rails used as intended can be a real pain to upgrade, I agree. Recently I have been developing applications in the "thin-model, thin-controller, with a service layer and external API wrappers" style, as espoused by Gary Bernhardt 1 and others 2 3 4 5. I upgraded to the latest Rails this morning on one app, and apart from swapping the Money gem to use the git repository, until they have a new version out with compatible dependency, it went smoothly. All the specs and acceptance tests passing with no alteration required. 1 link 2 link 3 link 4 link 5 link to this video