gmmcal/gmmcal.com.br

Rethink code organization

Closed this issue · 1 comments

Describe the solution you'd like
Research if it makes sense to restructure the application code like http://tomrothe.de/posts/rails_parts.html, pushing all code related to each model into a separated part, including CMS management, vue components, CSS, etc.

Even though this seems to be a very interesting approach, 2 things made me decide to close this issue:

  • Javascript packs are not well supported and must be placed in a single folder. It is possible to keep the pack on core, but it implies in a harder navigation on directory tree to include dependent components.
  • Brakeman stopped working complaining that it was not a valid rails application. I personally prefer to have a monitoring gem like brakeman than having a different structure for no particular reason.

On the other end, moving from a tested classic rails application to the proposed structure was almost effortless. The major changes were regarding fixtures paths on tests. No tests or code had to be completely changed to adapt to the proposed structure.

As an alternative approach, service objects, interactors and listeners are also a good way to refactor a rails application to a less coupled application. This approach does not apply in this project due to it's size, but any medium application can easily benefit from it.