Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
Rails apps start nice and cute. Fast forward a year and business logic and view logic are entangled in our validations and callbacks - getting in our way at every turn. Wasn’t this supposed to be easy? Let’s explore different approaches to improve the situation and untangle the web. By Tobias Pfeiffer https://twitter.com/@pragtob Tobias Pfeiffer is a clean coder, Full Stack developer, Benchmarker by passion, Rubyist, Elixir fan, learner, teacher and agile crafter by passion. He organizes the Ruby User Group Berlin, maintains Shoes and benchee as well as contributing to a variety of projects while thinking about new ideas to put into code and push boundaries. He loves collaboratively creating just about anything people enjoy. Currently he’s creating wonderful web applications, most recently with Elixir and Phoenix refreshing his perspective on web applications. https://rubyonice.com/speakers/tobias_pfeiffer
Date
Summarized using AI?
If this talk's summary was generated by AI, please check this box. A "Summarized using AI" badge will be displayed in the summary tab to indicate that the summary was generated using AI.
Show "Summarized using AI" badge on summary page
Summary
Markdown supported
In the talk titled "Do You Need That Validation? Let Me Call You Back About It," Tobias Pfeiffer discusses the complications that arise from intertwining validation logic and model callbacks in Ruby on Rails applications. He shares insights on how these practices can lead to convoluted code, debugging challenges, and performance issues as business and view logic become entangled over time. **Key Points Discussed:** - **Problems with Callbacks:** Pfeiffer introduces the concept of 'before-validation' callbacks, illustrating their pitfalls through a story about building an event management application. He emphasizes how such callbacks can obscure debugging by causing unexpected behavior in the application if not carefully managed. - **Common Validation Practices:** Using the GitLab user model as an example, he critiques the excessive custom validations resulting from specific view-related concerns that inevitably clutter model logic. - **Performance and Test Setup Issues:** Pfeiffer explains how constant validations can inflate test setup complexity and runtime by requiring multiple database records for validation checks, thus increasing the overall performance burden when testing. - **Affordances in Code Logic:** He makes a case for re-evaluating how models are structured within the Rails MVC architecture, arguing for clearer separation between business logic and validation logic. - **Alternative Solutions:** He explores various methodologies to address these challenges, including: - **Form Objects:** Simplifying the validation process without entangling models with unnecessary validations. - **Inheritance and Active Type:** Using inheritance to create models devoid of excess logic. - **Change Sets in Functional Programming:** Describing a more structured data manipulation concept he admires in Elixir, emphasizing its benefits in clarity and organization. - **Separation of Operations and Validators:** Advocating for a clean structure between controller actions and business logic to improve maintainability and clarity. In conclusion, Pfeiffer urges developers to critically assess their use of validations and callbacks, prioritizing a cleaner, more manageable structure in their Rails code. By acknowledging common pitfalls and adopting alternative approaches, Rails developers can enhance their code quality and streamline their applications. This talk highlights the balance between leveraging Rails effectively and managing complexity in code architecture.
Suggest modifications
Cancel