Rails: How do I make my rails project a Hexagonal rails project?
Asked Answered
O

1

4

I attended a meetup yesterday on scaling Rails, and one topic was Hexagonal Rails. However, I've only been doing Rails for a year, and am really comfortable (maybe too comfortable) with the MVC structure, so I don't really understand what adapter and message queue are.

Here's an article about it: http://victorsavkin.com/post/42542190528/hexagonal-architecture-for-rails-developers

And a pic: http://blog.mattwynne.net/wp-content/uploads/2012/06/hexagonal_architecture_sketch.jpg

To my understanding, I think it's about decoupling the parts so that actions are specifically filtered and passed to certain places of your application instead of having a central "router" for everything. I think this results in minimizing the use of ActiveRecord and the creation of a bunch of modules? I am pretty stumped on this so I have a few questions:

  1. To make my project a Hexagonal Rails project, where exactly do I put these modules (what folder? Do I create a new folder of a specific name?)

  2. Is this more for internal maintenance? For security?

From what I know, if a rails app gets too large can't you just split certain parts into another app (I believe it's called service oriented architecture?) and just make requests to it from your main app? Or perhaps use a load balancer + multiple servers if traffic gets too heavy.

Ossicle answered 15/11, 2013 at 21:44 Comment(1)
The wisper gem might be useful for decoupling of concerns: github.com/krisleech/wisper There are also examples and articles in the Wiki.Tyner
M
0

The Victor Savkin post you linked to put it well:

The hexagonal architecture helps separate the application from the delivery mechanism.

My understanding is that Hexagonal Architecture has its roots in the view of Rails as just a "delivery mechanism" (possibly one of many) for your actual application. It is an attempt to isolate your app from Rails and goes way beyond what people are trying to do when they are just splitting an app into smaller pieces with engines.

DHH (the creator of Rails) views the Hex architecture as "TDD induced design damage" and there has been a series of talks with the creator of TDD (Kent Beck) and Martin Fowler which you should definitely watch.

My answer to your question would be: don't. The conversation about Hexagonal Architecture is happening right now. Unless you have some burning need to separate your application code from Rails, I suggest you watch the talks and wait until the dust settles to see what comes out of all this.

Maxwellmaxy answered 4/6, 2014 at 2:11 Comment(1)
Two years later, has your viewpoint on this topic changed or remained the same? My rails app is growing rather quickly and I am looking to improve my codebase but I am a junior web dev so I am having much difficulty refactoring my website. Many thank in advance.Massorete

© 2022 - 2024 — McMap. All rights reserved.