[LRUG] Objects and on Hexagonal Rails

Chris Parsons chris.p at rsons.org
Tue Jul 23 23:32:35 PDT 2013


On Tue, Jul 23, 2013 at 08:53:23pm +0100, Murray Steele wrote:
>I think this is key.  If you build a standard rails app you are in very
>real terms "on rails"; there's a single approach you can take to build the
>app and you don't really have to think much as there's so much What Has
>Gone Before wisdom out there.  If you take the OO / Hexagonal approach
>pretty much everything you do is going to require A Decision About
>Something New.  Like Roland, I don't think that's a bad thing, but I do
>worry that it means it's easier to make poor decisions.

I also worry that less experienced developers who take the standard
Rails approach don't actually understand the reasons for the decisions
they're making, which means that sooner or later they will end up in
a mess that they don't have the skills to recover from. In effect we
can end up masking lack of experience with standard decisions, which
can leave developers out of their depth when things get more complex.
Bringing those decisions forward can highlight lack of experience in a
team early, allowing them to bring on a good senior to help guide their
decisions before they get in trouble.

As apps don't stay new very long, most developers work for most of their
time on larger older apps, rather than fresher newer ones. Therefore I'd
prefer the app to be easy to work with when it's big and ugly, which
means trying for a more OO approach has merit.

I actually don't think it's that hard to understand and read good OO
code, even for a less experienced coder. It's easier to understand
boilerplate rails code because we are used to seeing those abstractions
in other apps, but that's often because contort our domain to fit
inside the standard abstractions. Code that is set free from these
constraints can be surprisingly simple to follow.

>There's lots of people saying "Hey, you should totes do stuff this new way.
>Maintainability FTW!" but not a lot of "and here is how. WOO!".  Maybe
>someone can prove me wrong though; do you know of any good, real-world,
>examples to look at?

I've been working on a small project for a charity in Thamesmead in this
style. Thankfully they've agreed to make open source. It uses the Extreme
Isolation stuff I've started to blog about [1], which is an attempt to marry
Gary Bernhardt's views on seperating arrangement from work with the
Hexagonal rails approach.

I'm not happy with the approach I outline in this app yet. There is
extra work to create things. The Crud module I've pulled out still
requires a lot of work in the individual controllers (well, Rack apps
- it's Sinatra.) I'm not sure that I've got the abstractions right.
Comments and feedback very welcome!

https://github.com/thinkcodelearn/discover

Chris

[1] http://chrismdp.com/tag/extreme%20isolation/

-- 
Chris Parsons
chris.p at rsons.org
http://chrismdp.com
http://twitter.com/chrismdp



More information about the Chat mailing list