• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
ActiveRecord Callbacks. Готовим правильно.
 

ActiveRecord Callbacks. Готовим правильно.

on

  • 427 views

Павел Габриэль (Ruby/Rails разработчик, Agile-тренер, коуч)

Павел Габриэль (Ruby/Rails разработчик, Agile-тренер, коуч)
Доклад: ActiveRecord Callbacks. Готовим правильно.

Statistics

Views

Total Views
427
Views on SlideShare
405
Embed Views
22

Actions

Likes
0
Downloads
2
Comments
0

2 Embeds 22

http://brug.by 21
https://twitter.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    ActiveRecord Callbacks. Готовим правильно.  ActiveRecord Callbacks. Готовим правильно. Presentation Transcript

    • ActiveRecord::Callbacks Готовим правильно Павел Габриель / @alovak
    • AR::Callbacks before_create / save / update / validate after_*
    • Что не так с AR::Callbacks?
    • “That’s a total of twelve callbacks, which gives you immense power to react and prepare for each state in the ActiveRecord life cycle.” — active_record/callbacks.rb
    • “That’s Ruby, which gives you immense power to do, you know, pretty much anything, ever” — Ernie Miller
    • Google “Are ActiveRecord Callbacks Any Good?” “ActiveRecord Callbacks are Unreasonable” “Rails, callbacks, workers, and the race you never expected to lose”
    • “ActiveRecord's Callbacks Ruined My Life”
    • В чем же проблема?
    • Проблема? 
    • Single Responsibility Principle
    • “A class should do the smallest possible useful thing; that is, it should have a single responsibility.” — Sandi Metz
    • SRP Violation К лишнему весу ..
    • SRP Violation К усложнению кода
    • SRP Violation К сложным тестам Невозможности повторного использования И т.д.
    • Варианты решений
    • Вариант с Dependency Injection
    • Вариант с Service
    • Вариант с Events/Signals
    • ActiveSupport::Notifications
    • Wisper (gem)
    • • Минимизируйте зависимости с помощью Dependency Injection • Объединяйте несколько моделей в Service • Используйте Events/Signals
    • “Rails makes it natural and easy to build large, well-designed OOP systems.” — ????????
    • “Rails makes it natural and easy to build large, well-designed OOP systems.” — Nobody
    • Rails has no brain; use your own!
    • Спасибо! alovak@gmail.com