RailsConf 2023 - Rails as a piece of birthday cake by Vladimir Dementyev

Ғылым және технология

Ruby on Rails as a framework follows the Model-View-Controller design pattern. Three core elements, like the number of layers in a traditional birthday cake, are enough to “cook” web applications. However, on the long haul, the Rails cake often resembles a crumble cake with the layers smeared and crumb-bugs all around the kitchen-codebase.
Similarly to birthday cakes, adding new layers is easier to do and maintain as the application grows than increasing the existing layers in size.
How to extract from or add new layers to a Rails application? What considerations should be taken into account? Why is rainbow cake the king of layered cakes? Join my talk to learn about the layering Rails approach to keep applications healthy and maintainable.

Пікірлер: 3

  • @caws
    @caws Жыл бұрын

    Nice. Great talk! I have been using form objects not that dissimilar to what's shown for some time now and they are a great addition to any ruby developer toolbox (specially when handling complicated data structures that do not match 1 to 1 with models). I do have a question regarding the form object base class shown at 41:18. Does it not break SRP? From what I can tell it is validating the data, triggering side effects via callbacks and interfacing with the database. Dependency injection also seems to be made harder as one cannot easily inject dependencies into an ActiveModel-backed class (maybe as a parameter?) PS: I always saw form objects as classes that have the sole responsibility of validating data introduced by users, hence my question/doubt. PS2: Come to think of it, maybe these concerns do not apply if you take into account the idea of keeping close to rails conventions. Thanks!

  • @VladDem

    @VladDem

    9 ай бұрын

    Just found the comment 🙂 Sorry for late response You kinda answered it in "PS2". I would re-phrase the "PS" as "the primary responsibilities of the form object are to validate input (or convert it into a known type) and to provide meaningful feedback to users"; everything else is secondary and can be subsequently extracted into lower levels if necessary; but I wouldn't do that for every form object-splitting the operation into multiple objects just for the sake of "cleaner" design may lead to worse maintainability, not better.

Келесі