$30 off During Our Annual Pro Sale. View Details »

Component-based Ruby and Rails Architectures @ Mountain West Ruby 2013

shagemann
April 05, 2013

Component-based Ruby and Rails Architectures @ Mountain West Ruby 2013

How to organize Ruby and Rails codebases into small(er) components. The 8 steps can be found as tags in the sample repository: github.com/shageman/the_next_big_thing

shagemann

April 05, 2013
Tweet

More Decks by shagemann

Other Decks in Technology

Transcript

  1. Saturday, April 6, 13

    View Slide

  2. The end to my last talk
    Saturday, April 6, 13

    View Slide

  3. All
    gems
    start with a namespace
    Saturday, April 6, 13

    View Slide

  4. No
    Rails app
    starts with a namespace
    Saturday, April 6, 13

    View Slide

  5. Rails Gems
    Saturday, April 6, 13

    View Slide

  6. (a gorgeous and
    infinite nothingness)
    Rails Gems
    Saturday, April 6, 13

    View Slide

  7. (a gorgeous and
    infinite nothingness
    with all the bells and
    whistles of active*)
    Rails Gems
    Saturday, April 6, 13

    View Slide

  8. Try this!
    Namespace everything
    in your next app
    Saturday, April 6, 13

    View Slide

  9. Give yourself a box so
    you can start thinking
    outside of it
    Saturday, April 6, 13

    View Slide

  10. Component-based Ruby
    and Rails Architectures
    Stephan Hagemann
    Saturday, April 6, 13

    View Slide

  11. Saturday, April 6, 13

    View Slide

  12. Let’s talk about large apps
    Saturday, April 6, 13

    View Slide

  13. Never build large apps.
    Saturday, April 6, 13

    View Slide

  14. Saturday, April 6, 13

    View Slide

  15. Your app wants to kill you!
    Sandi Metz
    Saturday, April 6, 13

    View Slide

  16. HTTP://WWW.FLICKRIVER.COM/PHOTOS/REXY85/263649949/
    Saturday, April 6, 13

    View Slide

  17. HTTP://WWW.PBASE.COM/SIGMADSLR/IMAGE/34745521
    Saturday, April 6, 13

    View Slide

  18. HTTP://WWW.PELAPAPAS.COM.MX/HTMLS/GENTE_ANIMALES.HTML
    Saturday, April 6, 13

    View Slide

  19. The secret to building large
    apps is never build large
    apps.
    Justin Meyer
    Saturday, April 6, 13

    View Slide

  20. The secret to building large
    apps is never build large
    apps. Break your applications
    into small pieces. Then,
    assemble those testable, bite-
    sized pieces into your big
    application
    Justin Meyer
    Saturday, April 6, 13

    View Slide

  21. But how?
    Saturday, April 6, 13

    View Slide

  22. github.com/shageman/the_next_big_thing
    Saturday, April 6, 13

    View Slide

  23. Saturday, April 6, 13

    View Slide

  24. 5 looser coupling
    3 gems
    1 one app
    4 engines
    8 HTTP SOA
    2 modules
    7 eco-system
    6 services
    Saturday, April 6, 13

    View Slide

  25. 1
    The one app
    Saturday, April 6, 13

    View Slide

  26. Remember!
    a gorgeous and infinite
    nothingness
    with all the bells and
    whistles of active*
    Saturday, April 6, 13

    View Slide

  27. HTTP://WWW.FLICKR.COM/PHOTOS/WIDNR/6589525327/
    Saturday, April 6, 13

    View Slide

  28. ANNOYANCE
    ENTRY
    STRUCTURE
    Saturday, April 6, 13

    View Slide

  29. 2
    The modularized app
    Saturday, April 6, 13

    View Slide

  30. +
    A higher level structure
    Saturday, April 6, 13

    View Slide

  31. HTTP://WWW.FLICKR.COM/PHOTOS/WIDNR/6589525327/
    Saturday, April 6, 13

    View Slide

  32. HTTP://EECUE.COM/P/31426/METAL-RECYCLING-YARD.HTML
    Saturday, April 6, 13

    View Slide

  33. ANNOYANCE
    EMAIL
    SIGNUP
    STRUCTURE
    Saturday, April 6, 13

    View Slide

  34. 3
    The gem component app
    Saturday, April 6, 13

    View Slide

  35. +
    Provably independent tests
    Saturday, April 6, 13

    View Slide

  36. Choose modules that tell
    the story of the system
    and contain a cohesive
    set of concepts
    Eric Evans
    Saturday, April 6, 13

    View Slide

  37. Saturday, April 6, 13

    View Slide

  38. HTTP://WWW.SMASHINGMAGAZINE.COM/INFORMATION-AND-INSTRUCTIONAL-SIGNS-PART-1/
    Saturday, April 6, 13

    View Slide

  39. ANNOYANCE
    EMAIL
    SIGNUP
    STRUCTURE
    Saturday, April 6, 13

    View Slide

  40. 4
    The Rails component app
    Saturday, April 6, 13

    View Slide

  41. +
    Provable structure for Rails
    Saturday, April 6, 13

    View Slide

  42. Rails Engines
    Saturday, April 6, 13

    View Slide

  43. Engines are not just for
    pagination, generic
    admin, and authentication
    Saturday, April 6, 13

    View Slide

  44. Engines are not just
    kaminari, generic admin,
    and authentication
    Saturday, April 6, 13

    View Slide

  45. Engines are not just
    kaminari, active admin,
    and authentication
    Saturday, April 6, 13

    View Slide

  46. Engines are not just
    kaminari, active admin,
    and devise
    Saturday, April 6, 13

    View Slide

  47. Rails::Engine allows you to wrap a
    specific Rails application or subset of
    functionality and share it with other
    applications or within a larger
    packaged application.
    http://edgeapi.rubyonrails.org/classes/
    Rails/Engine.html
    Saturday, April 6, 13

    View Slide

  48. EMAIL
    SIGNUP
    TEASER
    STRUCTURE
    ANNOYANCE
    Saturday, April 6, 13

    View Slide

  49. What code smell did
    you see?
    Saturday, April 6, 13

    View Slide

  50. Single Responsibility
    Saturday, April 6, 13

    View Slide

  51. 5
    The loosely-coupled app
    Saturday, April 6, 13

    View Slide

  52. +
    Clearer responsibilities
    Saturday, April 6, 13

    View Slide

  53. EMAIL
    SIGNUP
    TEASER
    STRUCTURE
    ANNOYANCE
    EVENT
    COUNTER
    Saturday, April 6, 13

    View Slide

  54. 6
    The service-oriented app
    Saturday, April 6, 13

    View Slide

  55. +
    Reduced surface area
    Saturday, April 6, 13

    View Slide

  56. 588 194
    LOGGER::COUNT
    EVENTCOUNTER::*.METHODS.COUNT
    LOGGER
    361 115
    Saturday, April 6, 13

    View Slide

  57. 588 194
    LOGGER::COUNT
    EVENTCOUNTER::*.METHODS.COUNT
    LOGGER
    361 115
    - OBJECT.METHODS
    LOGGER::COUNT LOGGER
    394 0
    247 1
    Saturday, April 6, 13

    View Slide

  58. EMAIL
    SIGNUP
    TEASER
    STRUCTURE
    ANNOYANCE
    EVENT
    COUNTER
    Saturday, April 6, 13

    View Slide

  59. 7
    The eco-system app
    Saturday, April 6, 13

    View Slide

  60. gem build event_counter..
    Saturday, April 6, 13

    View Slide

  61. gem push event_counter..
    Saturday, April 6, 13

    View Slide

  62. Saturday, April 6, 13

    View Slide

  63. EMAIL
    SIGNUP
    TEASER
    STRUCTURE
    ANNOYANCE
    EVENT
    COUNTER
    Saturday, April 6, 13

    View Slide

  64. 8
    The HTTP SOA app
    Saturday, April 6, 13

    View Slide

  65. Saturday, April 6, 13

    View Slide

  66. STRUCTURE
    EMAIL
    SIGNUP
    TEASER
    ANNOYANCE
    EVENT COUNTER
    Saturday, April 6, 13

    View Slide

  67. Saturday, April 6, 13

    View Slide

  68. 5 looser coupling
    3 gems
    1 one app
    4 engines
    8 HTTP SOA
    2 modules
    7 eco-system
    6 services
    Saturday, April 6, 13

    View Slide

  69. Saturday, April 6, 13

    View Slide

  70. Saturday, April 6, 13

    View Slide

  71. 5 looser coupling
    3 gems
    1 one app
    4 engines
    8 HTTP SOA
    2 modules
    7 eco-system
    6 services
    Saturday, April 6, 13

    View Slide

  72. Thanks!
    Stephan Hagemann
    @shageman
    [email protected]
    Saturday, April 6, 13

    View Slide