Slide 1

Slide 1 text

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

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

Disclaimer: nothing I might say other people say, they actually say. except when I say so. Monday, September 24, 2012

Slide 4

Slide 4 text

When you see this on a slide: the-next-big-thing.herokuapp.com/ Monday, September 24, 2012

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

Never build large apps. Monday, September 24, 2012

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

Wrangling stuff Monday, September 24, 2012

Slide 10

Slide 10 text

Monday, September 24, 2012

Slide 11

Slide 11 text

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

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

Never build large apps. Monday, September 24, 2012

Slide 15

Slide 15 text

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

Slide 16

Slide 16 text

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

Slide 17

Slide 17 text

Monday, September 24, 2012

Slide 18

Slide 18 text

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

Slide 19

Slide 19 text

Yehuda is like: grmpf! that’s like throwing all that on a big pile!! Ugly Monday, September 24, 2012

Slide 20

Slide 20 text

HTTP://WWW.FLICKR.COM/PHOTOS/WIDNR/6589525327/ Monday, September 24, 2012

Slide 21

Slide 21 text

Structured Monday, September 24, 2012

Slide 22

Slide 22 text

Comprehendible Monday, September 24, 2012

Slide 23

Slide 23 text

Agile Monday, September 24, 2012

Slide 24

Slide 24 text

Focused Monday, September 24, 2012

Slide 25

Slide 25 text

Structured Prevent the big pile Comprehendible Prevent cognitive overload Agile Allow for change Focused Allow for concentration Monday, September 24, 2012

Slide 26

Slide 26 text

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

Slide 27

Slide 27 text

Structured No. Comprehendible Hm. Agile Can’t tell. Focused Doesn’t seem so. Monday, September 24, 2012

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

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

Slide 30

Slide 30 text

Matz is like: We got namespaces: modules! Monday, September 24, 2012

Slide 31

Slide 31 text

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

Slide 32

Slide 32 text

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

Slide 33

Slide 33 text

Structured One more level at least! Comprehendible Modules might make sense Agile No change Focused Can’t prove it Monday, September 24, 2012

Slide 34

Slide 34 text

HTTP://WWW.FLICKR.COM/PHOTOS/BRENDA-STARR/3466702375/ Monday, September 24, 2012

Slide 35

Slide 35 text

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

Slide 36

Slide 36 text

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

Slide 37

Slide 37 text

I am like: Yes, but don’t put PaymentGateway in lib, put it in a gem! Monday, September 24, 2012

Slide 38

Slide 38 text

Gems bring their own specs with them! Monday, September 24, 2012

Slide 39

Slide 39 text

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

Slide 40

Slide 40 text

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

Slide 41

Slide 41 text

higher cohesion inside looser coupling outside Monday, September 24, 2012

Slide 42

Slide 42 text

The annoyance problem Monday, September 24, 2012

Slide 43

Slide 43 text

The annoyance gem Monday, September 24, 2012

Slide 44

Slide 44 text

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

Slide 45

Slide 45 text

You guys are like: Git submodules suck!! Monday, September 24, 2012

Slide 46

Slide 46 text

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

Slide 47

Slide 47 text

Gemfiles require by path Monday, September 24, 2012

Slide 48

Slide 48 text

Explicit dependencies! Monday, September 24, 2012

Slide 49

Slide 49 text

Structured Yes! Comprehendible Yes! Agile Yes! Focused Yes! Monday, September 24, 2012

Slide 50

Slide 50 text

Current Pivotal project Availability and Booking Rails Travel Site Payment Gateway Conversion Tracking Monday, September 24, 2012

Slide 51

Slide 51 text

But wait... Monday, September 24, 2012

Slide 52

Slide 52 text

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

Slide 53

Slide 53 text

Structured Yes! Comprehendible Yes! Agile Yes! Focused Yes! Rails? hm. Monday, September 24, 2012

Slide 54

Slide 54 text

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

Slide 55

Slide 55 text

Engines are not just for pagination, generic admin, and authentication Monday, September 24, 2012

Slide 56

Slide 56 text

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

Slide 57

Slide 57 text

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

Slide 58

Slide 58 text

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

Slide 59

Slide 59 text

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

Slide 60

Slide 60 text

Rails::Engine allows you to wrap a specific Rails application or subset of functionality and share it with yourself. -- Me Monday, September 24, 2012

Slide 61

Slide 61 text

Engines are easy Monday, September 24, 2012

Slide 62

Slide 62 text

Structured Yes! Comprehendible Yes! Agile Yes! Focused Yes! Rails? Yes! Monday, September 24, 2012

Slide 63

Slide 63 text

Details Monday, September 24, 2012

Slide 64

Slide 64 text

Engines are not magical! Monday, September 24, 2012

Slide 65

Slide 65 text

Mounting Monday, September 24, 2012

Slide 66

Slide 66 text

Assets Monday, September 24, 2012

Slide 67

Slide 67 text

Migrations Monday, September 24, 2012

Slide 68

Slide 68 text

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

Slide 69

Slide 69 text

Both gems and engines are just Monday, September 24, 2012

Slide 70

Slide 70 text

If you do them right, they tell the story of your app Monday, September 24, 2012

Slide 71

Slide 71 text

Do one thing Monday, September 24, 2012

Slide 72

Slide 72 text

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

Slide 73

Slide 73 text

No Rails app starts with a namespace Monday, September 24, 2012

Slide 74

Slide 74 text

Rails Gems Monday, September 24, 2012

Slide 75

Slide 75 text

Try this! Namespace everything in your next Rails app Monday, September 24, 2012

Slide 76

Slide 76 text

Give yourself a box so you can start thinking outside of it Monday, September 24, 2012

Slide 77

Slide 77 text

Thanks! Monday, September 24, 2012

Slide 78

Slide 78 text

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

Slide 79

Slide 79 text

“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