Wrangling Large Ruby Codebases @ Rocky Mountain Ruby 2012

Affa5b7b3a311fcf5f868859d586b410?s=47 shagemann
September 21, 2012

Wrangling Large Ruby Codebases @ Rocky Mountain Ruby 2012

As Rails applications grow they see a lot of the same problems that any enterprise level software project will see at some point: longer running test suites, more complex code interaction, and a rising requirement to keep "all that stuff" in your head at once.

Rails may have been a framework for single applications in the past, but it nowadays has some features that allow you to tackle bigger projects with more ease. We'll cover Rails code structuring techniques like unbuilt gems and engines that you can use to get faster test suites, cleaner structures, and more flexible apps.

Affa5b7b3a311fcf5f868859d586b410?s=128

shagemann

September 21, 2012
Tweet

Transcript

  1. Wrangling large Ruby codebases Stephan Hagemann Monday, September 24, 2012

  2. The next big Thing github.com/shageman/the_next_big_thing Monday, September 24, 2012

  3. Disclaimer: nothing I might say other people say, they actually

    say. except when I say so. Monday, September 24, 2012
  4. When you see this on a slide: the-next-big-thing.herokuapp.com/ Monday, September

    24, 2012
  5. When you see this on a slide: github.com/shageman/the_next_big_thing/ Monday, September

    24, 2012
  6. Let’s talk about large apps Monday, September 24, 2012

  7. Never build large apps. Monday, September 24, 2012

  8. Sandi: your app wants to kill you Monday, September 24,

    2012
  9. Wrangling stuff Monday, September 24, 2012

  10. Monday, September 24, 2012

  11. HTTP://WWW.FLICKRIVER.COM/PHOTOS/REXY85/263649949/ Monday, September 24, 2012

  12. HTTP://WWW.PBASE.COM/SIGMADSLR/IMAGE/34745521 Monday, September 24, 2012

  13. HTTP://WWW.PELAPAPAS.COM.MX/HTMLS/GENTE_ANIMALES.HTML Monday, September 24, 2012

  14. Never build large apps. Monday, September 24, 2012

  15. So... I built a tiny app Monday, September 24, 2012

  16. Ok, ok... big apps Monday, September 24, 2012

  17. Monday, September 24, 2012

  18. ACCOUNT_DELETER.RB ACCOUNT_DELETION.RB APP_CONFIG.RB ASPECT.RB ASPECT_MEMBERSHIP.RB ASPECT_VISIBILITY.RB BLOCK.RB COMMENT.RB CONTACT.RB CONVERSATION.RB

    CONVERSATION_VISIBILITY.RB FEATURE_FLAGGER.RB INVITATION.RB INVITATION_CODE.RB LIKE.RB MENTION.RB MESSAGE.RB NOTIFICATION.RB NOTIFICATION_ACTOR.RB O_EMBED_CACHE.RB OAUTH2_PROVIDER_MODELS_ACTIVERECORD_AUTHORIZATION.RB OAUTH2_PROVIDER_MODELS_ACTIVERECORD_CLIENT.RB PARTICIPATION.RB PERSON.RB PHOTO.RB POD.RB POST.RB PROFILE.RB RELAYABLE_RETRACTION.RB REQUEST.RB RESHARE.RB RETRACTION.RB ROLE.RB SERVICE.RB SERVICE_USER.RB SHARE_VISIBILITY.RB SIGNED_RETRACTION.RB STATUS_MESSAGE.RB TAG_FOLLOWING.RB USER.RB USER_PREFERENCE.RB Monday, September 24, 2012
  19. Yehuda is like: grmpf! that’s like throwing all that on

    a big pile!! Ugly Monday, September 24, 2012
  20. HTTP://WWW.FLICKR.COM/PHOTOS/WIDNR/6589525327/ Monday, September 24, 2012

  21. Structured Monday, September 24, 2012

  22. Comprehendible Monday, September 24, 2012

  23. Agile Monday, September 24, 2012

  24. Focused Monday, September 24, 2012

  25. Structured Prevent the big pile Comprehendible Prevent cognitive overload Agile

    Allow for change Focused Allow for concentration Monday, September 24, 2012
  26. ACCOUNT_DELETER.RB ACCOUNT_DELETION.RB APP_CONFIG.RB ASPECT.RB ASPECT_MEMBERSHIP.RB ASPECT_VISIBILITY.RB BLOCK.RB COMMENT.RB CONTACT.RB CONVERSATION.RB

    CONVERSATION_VISIBILITY.RB FEATURE_FLAGGER.RB INVITATION.RB INVITATION_CODE.RB LIKE.RB MENTION.RB MESSAGE.RB NOTIFICATION.RB NOTIFICATION_ACTOR.RB O_EMBED_CACHE.RB OAUTH2_PROVIDER_MODELS_ACTIVERECORD_AUTHORIZATION.RB OAUTH2_PROVIDER_MODELS_ACTIVERECORD_CLIENT.RB PARTICIPATION.RB PERSON.RB PHOTO.RB POD.RB POST.RB PROFILE.RB RELAYABLE_RETRACTION.RB REQUEST.RB RESHARE.RB RETRACTION.RB ROLE.RB SERVICE.RB SERVICE_USER.RB SHARE_VISIBILITY.RB SIGNED_RETRACTION.RB STATUS_MESSAGE.RB TAG_FOLLOWING.RB USER.RB USER_PREFERENCE.RB Monday, September 24, 2012
  27. Structured No. Comprehendible Hm. Agile Can’t tell. Focused Doesn’t seem

    so. Monday, September 24, 2012
  28. HTTP://WWW.FLICKR.COM/PHOTOS/CHAPSTICKADDICT/4721461500/ HTTP://WWW.FLICKR.COM/PHOTOS/41597157@N00/2515819924/ HTTP://WWW.FLICKR.COM/PHOTOS/41597157@N00/2475319232/ HTTP://WWW.FLICKR.COM/PHOTOS/CHAPSTICKADDICT/4721461500/ Monday, September 24, 2012

  29. ACCOUNT_DELETER.RB ACCOUNT_DELETION.RB APP_CONFIG.RB ASPECT.RB ASPECT_MEMBERSHIP.RB ASPECT_VISIBILITY.RB BLOCK.RB COMMENT.RB CONTACT.RB CONVERSATION.RB

    CONVERSATION_VISIBILITY.RB FEATURE_FLAGGER.RB INVITATION.RB INVITATION_CODE.RB LIKE.RB MENTION.RB MESSAGE.RB NOTIFICATION.RB NOTIFICATION_ACTOR.RB O_EMBED_CACHE.RB OAUTH2_PROVIDER_MODELS_ACTIVERECORD_A OAUTH2_PROVIDER_MODELS_ACTIVERECORD_C PARTICIPATION.RB PERSON.RB PHOTO.RB POD.RB POST.RB PROFILE.RB RELAYABLE_RETRACTION.RB REQUEST.RB RESHARE.RB RETRACTION.RB ROLE.RB SERVICE.RB SERVICE_USER.RB SHARE_VISIBILITY.RB SIGNED_RETRACTION.RB STATUS_MESSAGE.RB TAG_FOLLOWING.RB USER.RB USER_PREFERENCE.RB Monday, September 24, 2012
  30. Matz is like: We got namespaces: modules! Monday, September 24,

    2012
  31. ACCOUNT_DELETER.RB ACCOUNT_DELETION.RB APP_CONFIG.RB ASPECT.RB ASPECT_MEMBERSHIP.RB ASPECT_VISIBILITY.RB BLOCK.RB COMMENT.RB CONTACT.RB CONVERSATION.RB

    CONVERSATION_VISIBILITY.RB FEATURE_FLAGGER.RB INVITATION.RB INVITATION_CODE.RB LIKE.RB MENTION.RB MESSAGE.RB NOTIFICATION.RB NOTIFICATION_ACTOR.RB O_EMBED_CACHE.RB OAUTH2_PROVIDER_MODELS_ACTIVERECORD_A OAUTH2_PROVIDER_MODELS_ACTIVERECORD_C PARTICIPATION.RB PERSON.RB PHOTO.RB POD.RB POST.RB PROFILE.RB RELAYABLE_RETRACTION.RB REQUEST.RB RESHARE.RB RETRACTION.RB ROLE.RB SERVICE.RB SERVICE_USER.RB SHARE_VISIBILITY.RB SIGNED_RETRACTION.RB STATUS_MESSAGE.RB TAG_FOLLOWING.RB USER.RB USER_PREFERENCE.RB Monday, September 24, 2012
  32. ACCOUNT_DELETER.RB ACCOUNT_DELETION.RB APP_CONFIG.RB ASPECT.RB ASPECT_MEMBERSHIP.RB ASPECT_VISIBILITY.RB BLOCK.RB COMMENT.RB CONTACT.RB CONVERSATION.RB

    CONVERSATION_VISIBILITY.RB FEATURE_FLAGGER.RB INVITATION.RB INVITATION_CODE.RB LIKE.RB MENTION.RB MESSAGE.RB NOTIFICATION.RB NOTIFICATION_ACTOR.RB O_EMBED_CACHE.RB OAUTH2_PROVIDER_MODELS_ACTIVERECORD_A OAUTH2_PROVIDER_MODELS_ACTIVERECORD_C PARTICIPATION.RB PERSON.RB PHOTO.RB POD.RB POST.RB PROFILE.RB RELAYABLE_RETRACTION.RB REQUEST.RB RESHARE.RB RETRACTION.RB ROLE.RB SERVICE.RB SERVICE_USER.RB SHARE_VISIBILITY.RB SIGNED_RETRACTION.RB STATUS_MESSAGE.RB TAG_FOLLOWING.RB USER.RB USER_PREFERENCE.RB User OAuth Interaction Memberships Don’t know Visibility Retraction Monday, September 24, 2012
  33. Structured One more level at least! Comprehendible Modules might make

    sense Agile No change Focused Can’t prove it Monday, September 24, 2012
  34. HTTP://WWW.FLICKR.COM/PHOTOS/BRENDA-STARR/3466702375/ Monday, September 24, 2012

  35. Carl is like: Gems!! Monday, September 24, 2012

  36. Ben is like: Depend upon abstractions! Monday, September 24, 2012

  37. I am like: Yes, but don’t put PaymentGateway in lib,

    put it in a gem! Monday, September 24, 2012
  38. Gems bring their own specs with them! Monday, September 24,

    2012
  39. Choose modules that tell the story of the system and

    contain a cohesive set of concepts -- Eric Evans Monday, September 24, 2012
  40. Choose modules that tell the story of the system and

    contain a cohesive set of concepts -- Eric Evans Monday, September 24, 2012
  41. higher cohesion inside looser coupling outside Monday, September 24, 2012

  42. The annoyance problem Monday, September 24, 2012

  43. The annoyance gem Monday, September 24, 2012

  44. Structured Yes! Comprehendible The gem is only dealing with its

    stuff Agile git submodule? separate repo? hm. Focused Yes! And you can prove it! Monday, September 24, 2012
  45. You guys are like: Git submodules suck!! Monday, September 24,

    2012
  46. I am like: Yep. Use unbuilt gems! Monday, September 24,

    2012
  47. Gemfiles require by path Monday, September 24, 2012

  48. Explicit dependencies! Monday, September 24, 2012

  49. Structured Yes! Comprehendible Yes! Agile Yes! Focused Yes! Monday, September

    24, 2012
  50. Current Pivotal project Availability and Booking Rails Travel Site Payment

    Gateway Conversion Tracking Monday, September 24, 2012
  51. But wait... Monday, September 24, 2012

  52. DHH is like: What about Rails? Monday, September 24, 2012

  53. Structured Yes! Comprehendible Yes! Agile Yes! Focused Yes! Rails? hm.

    Monday, September 24, 2012
  54. José is like: I got this. Engines! Monday, September 24,

    2012
  55. Engines are not just for pagination, generic admin, and authentication

    Monday, September 24, 2012
  56. Engines are not just kaminari, generic admin, and authentication Monday,

    September 24, 2012
  57. Engines are not just kaminari, active admin, and authentication Monday,

    September 24, 2012
  58. Engines are not just kaminari, active admin, and devise Monday,

    September 24, 2012
  59. Rails::Engine allows you to wrap a specific Rails application or

    subset of functionality and share it with other applications. -- http://api.rubyonrails.org/ Monday, September 24, 2012
  60. Rails::Engine allows you to wrap a specific Rails application or

    subset of functionality and share it with yourself. -- Me Monday, September 24, 2012
  61. Engines are easy Monday, September 24, 2012

  62. Structured Yes! Comprehendible Yes! Agile Yes! Focused Yes! Rails? Yes!

    Monday, September 24, 2012
  63. Details Monday, September 24, 2012

  64. Engines are not magical! Monday, September 24, 2012

  65. Mounting Monday, September 24, 2012

  66. Assets Monday, September 24, 2012

  67. Migrations Monday, September 24, 2012

  68. Current Pivotal Project Rails TV Shows with Social Network Global

    Admin Show Admin SMS Interface Social Network Publisher Admin UI Users and Channels Monday, September 24, 2012
  69. Both gems and engines are just Monday, September 24, 2012

  70. If you do them right, they tell the story of

    your app Monday, September 24, 2012
  71. Do one thing Monday, September 24, 2012

  72. All gems start with a namespace Monday, September 24, 2012

  73. No Rails app starts with a namespace Monday, September 24,

    2012
  74. Rails Gems Monday, September 24, 2012

  75. Try this! Namespace everything in your next Rails app Monday,

    September 24, 2012
  76. Give yourself a box so you can start thinking outside

    of it Monday, September 24, 2012
  77. Thanks! Monday, September 24, 2012

  78. Stephan Hagemann stephan@pivotallabs.com @shageman github.com/shageman pivotallabs.com/users/shagemann/blog Monday, September 24, 2012

  79. “The secret to building large apps is never build large

    apps. Break your application into small pieces. Then, assemble those testable, bite-sized pieces into your big application” -- Justin Meyer, JavascriptMVC Monday, September 24, 2012