Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Practical SOLID with Rails

Practical SOLID with Rails

Ruby Meditation s.1, e.1, Kiev

Andrey Savchenko

February 23, 2013
Tweet

More Decks by Andrey Savchenko

Other Decks in Programming

Transcript

  1. Practical SOLID
    with Rails
    Andrey Savchenko
    CTO @ Aejis
    Tuesday, March 19, 13

    View full-size slide

  2. Let’s start the our new, awesome project!
    Tuesday, March 19, 13

    View full-size slide

  3. class < ActiveRecord::Base
    belongs_to :company
    has_many :products
    has_many :warehouses
    validates_presence_of :name
    end
    Tuesday, March 19, 13

    View full-size slide

  4. Tuesday, March 19, 13

    View full-size slide

  5. 10 months later...
    Tuesday, March 19, 13

    View full-size slide

  6. Tuesday, March 19, 13

    View full-size slide

  7. Tuesday, March 19, 13

    View full-size slide

  8. SOLID
    Tuesday, March 19, 13

    View full-size slide

  9. SOLID
    • Single responsibility principle
    • Open-Closed principle
    • Liskov substitution principle
    • Interface segregation principle
    • Dependency inversion principle
    Tuesday, March 19, 13

    View full-size slide

  10. SRP
    • Easy to read
    • Easy to change
    • Easy to reuse
    No god objects
    Tuesday, March 19, 13

    View full-size slide

  11. Tuesday, March 19, 13

    View full-size slide

  12. Tuesday, March 19, 13

    View full-size slide

  13. Tuesday, March 19, 13

    View full-size slide

  14. Tuesday, March 19, 13

    View full-size slide

  15. Tuesday, March 19, 13

    View full-size slide

  16. Tuesday, March 19, 13

    View full-size slide

  17. Tuesday, March 19, 13

    View full-size slide

  18. Tuesday, March 19, 13

    View full-size slide

  19. Tuesday, March 19, 13

    View full-size slide

  20. Tuesday, March 19, 13

    View full-size slide

  21. PROFIT!?
    Tuesday, March 19, 13

    View full-size slide

  22. So much objects? NO!
    Tuesday, March 19, 13

    View full-size slide

  23. YES!
    • https://github.com/drapergem/draper
    • https://github.com/mbj/aequitas
    • https://github.com/Ptico/resourced
    • https://github.com/bogdan/datagrid
    Tuesday, March 19, 13

    View full-size slide

  24. OCP
    Tuesday, March 19, 13

    View full-size slide

  25. Tuesday, March 19, 13

    View full-size slide

  26. Tuesday, March 19, 13

    View full-size slide

  27. LSP
    Tuesday, March 19, 13

    View full-size slide

  28. ISP
    Tuesday, March 19, 13

    View full-size slide

  29. DI
    Tuesday, March 19, 13

    View full-size slide

  30. Tuesday, March 19, 13

    View full-size slide

  31. Tuesday, March 19, 13

    View full-size slide

  32. Picture with cat
    Because everyone loves cats <3
    Tuesday, March 19, 13

    View full-size slide

  33. Questions?
    • Twitter: @ptico
    • Github: @ptico
    Tuesday, March 19, 13

    View full-size slide