4

I recently came across Robert Martin's (Uncle Bob) keynote on how to structure a rails app based on use-cases. I found this very interesting.

Here is the link to the keynote: Architecture: the Lost Years

Here is a sample project that structures the app based on the principles mentioned by Robert Martin in his keynote: Guru Watch

I was wondering if there were well established rails applications out there that are structured in such fashion (Use Case Driven Approach / Entity-Control-Boundary architecture / decoupling back end from front-end)

tereško
  • 58,060
  • 25
  • 98
  • 150
Karan
  • 14,824
  • 24
  • 91
  • 157
  • 1
    you might be interested in http://blog.firsthand.ca/2011/10/rails-is-not-your-application.html – apneadiving Jan 07 '13 at 12:43
  • this might interest you http://stackoverflow.com/questions/8743937/practical-example-of-architecture-using-ebc – Helio Santos Jan 07 '13 at 17:43
  • I can't offer an answer, but I've found the Destroy All Software screencasts to offer interesting advice in terms of generally decoupling your application, using service classes, keeping your ActiveRecord models a truly thin data-only layer, etc. The screencasts aren't free, unfortunately, and many are on really tangential subjects, but they might be a good starting point. Here's the catalog: https://www.destroyallsoftware.com/screencasts/catalog – Nerdmaster Jan 16 '14 at 17:57

1 Answers1

2

Well, I can't share the code, but I can point you to some direction. We've been using this gem in our application: https://github.com/collectiveidea/interactor.

I was heavily inspired by Martin's keynote, and this app' development went pretty well :). In case of ActiveRecord and Business Logic separation, we did the following:

Each class in our business logic had somekind of DatabaseEntity counterpart. This counterpart was using another class - our adapter to ActiveRecord. It was querying corresponding ActiveRecord model and converting ActiveRecord instances to instances of our business logic classes.

After all, most of the code was concentrated in this adapter.

marvelousNinja
  • 1,510
  • 9
  • 15
  • Can you tell how hard was to implement that solution? And to you it was worth the extra overhead to the work in those classes against the design and easier to understand and refactor the core logic of the application? – cllamach Jun 08 '16 at 03:57