There's been a recent surge in the Ruby community of blog posts, tweets, and comments on the benefits of using better OO design, and specifically separating business logic from persistence logic. Especially for larger apps, I see this as excellent advice.
I'm interested to find a complete example Rails app where the business logic and been completely decoupled from the ORM (ActiveRecord or otherwise). Specifically, I'm interesting in seeing how one might handle DB constraints, business rule validation, parameter cleaning, service classes, etc.
Anyone know of an open-source app like this?
The ones I am familiar with are from Jeff Casimir (@j3). Here is his presentation from Railsconf 2011. He also created a gem called draper that uses some of those ideas. Ryan Bates made a rails cast using it so hopefully that gives you some ideas.
As far as I know - railists approach modeling business quite differently. They more or less consciously drive design in data-centric way. It might seem contradictory and bad if we cling to e.g. object orientation.
But, as christians say: "freedom comes from constraints".
If we are able to express our domain in CRUD like fashion, we greatly decrease technical complexity, get REST for free etc.
This blog post explains it better than I do (don't miss presentation by DHH)
And here's some insight from Scott Belware on this topic.
But if you insist and want to experiment a bit, you might want to try data-mapper.
Unfortunately, haven't tried that out yet, so - can't comment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With