The Even Darker Art Of Rails Engines Presentation
Upcoming SlideShare
Loading in...5
×

Like this? Share it with your network

Share
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,386
On Slideshare
2,383
From Embeds
3
Number of Embeds
1

Actions

Shares
Downloads
22
Comments
0
Likes
7

Embeds 3

http://www.slideshare.net 3

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. The Even-Darker Art of Rails Engines
  • 2. @lazyatom
  • 3. github.com/lazyatom/engines
  • 4. Rails 2.3
  • 5. history
  • 6. November 2005
  • 7. it’s distracting!
  • 8. reuse is overrated!
  • 9. Evil! Evil! Evil! Evil! Evil! Evil! Evil! Evil! Shit!
  • 10. eek!
  • 11. appable_plugins
  • 12. desert
  • 13. merb slices?
  • 14. engines
  • 15. !quot;#$%&!quot;#$'#(%&$#)&!quot;#$%&*$+,#-.!) !quot;#$%&'() $$*%&'()$++,$-'%!.%&'()./0#'12%)/'0 quot;0! 3$405/0quot;6$%1quot;$7-(5/06$8/)9$%0$%77:$!/1quot;;)'1<= !quot;#$quot;05/0quot;> $$9%6.%77.!/1quot;;)'1<> quot;0! 3$?quot;)(106$)1(quot;$/#$)9quot;$quot;05/0quot;$69/76$8/)9$%$1'()/05$#/-quot; !quot;#$1'()quot;!> $$@/-quot;=quot;A/6)>B1'()/05.#/-quot;C quot;0! !quot;#$D/quot;8.7%)9 $$@/-quot;=E'/0B!/1quot;;)'1<F$G%77GF$GD/quot;86GC quot;0!
  • 16. app/controllers/ models/ helpers/ views/ metal/
  • 17. *$+,#-&quot;**&23-'!3$$(!&*$+,#-523-'!3$$(!.!) ;-%66$H-(5/0I'0)1'--quot;1/0/1**$#2quot;'#3-43-'!3$$(! $$!quot;#$/0!quot;A $$$$1quot;0!quot;1$J)quot;A)$,K$LMquot;--'F$H-(5/0NL $$quot;0! quot;0!
  • 18. 9quot;-7quot;1$J%-- won’t load from your plugin
  • 19. Ticket #1905
  • 20. config/routes.rb
  • 21. *$+,#-&23-6#,&!3+'(%.!) O;)/'0I'0)1'--quot;1JJ?'()/05JJ?'()quot;6=!1%8$!'$+2%7+ $$2%7=;'00quot;;)$G:7%)9GF$J;'0)1'--quot;1$,K$L7-(5/0LF$ $$$$$$$$$$$$$$$$$$$$$$$J%;)/'0$,K$L/0!quot;AL quot;0!
  • 22. top precedence
  • 23. in your plugin: O;)/'0I'0)1'--quot;1JJ?'()/05JJ?'()quot;6=!1%8$!'$+2%7+ $$2%7=;'00quot;;)$G:7%)9GF$J;'0)1'--quot;1$,K$L7-(5/0LF$ $$$$$$$$$$$$$$$$$$$$$$$J%;)/'0$,K$L/0!quot;AL quot;0! in your app: O;)/'0I'0)1'--quot;1JJ?'()/05JJ?'()quot;6=!1%8$!'$+2%7+ $$3$===$')9quot;1$1'()quot;6$=== $$2%7=;'00quot;;)$G:7%)9GF$J;'0)1'--quot;1$,K$L%77LF$ $$$$$$$$$$$$$$$$$$$$$$$J%;)/'0$,K$L/0!quot;AL $$3$===$')9quot;1$1'()quot;6$=== quot;0!
  • 24. in your plugin: O;)/'0I'0)1'--quot;1JJ?'()/05JJ?'()quot;6=!1%8$!'$+2%7+ $$2%7=;'00quot;;)$G:7%)9GF$J;'0)1'--quot;1$,K$L7-(5/0LF$ $$$$$$$$$$$$$$$$$$$$$$$J%;)/'0$,K$L/0!quot;AL quot;0! in your app: O;)/'0I'0)1'--quot;1JJ?'()/05JJ?'()quot;6=!1%8$!'$+2%7+ $$3$===$')9quot;1$1'()quot;6$=== $$2%7=;'00quot;;)$G:7%)9GF$J;'0)1'--quot;1$,K$L%77LF$ $$$$$$$$$$$$$$$$$$$$$$$J%;)/'0$,K$L/0!quot;AL $$3$===$')9quot;1$1'()quot;6$=== quot;0!
  • 25. Ticket #2592 (also Ticket #329)
  • 26. 785*$+,#-&$#)&785*$+,#-.!) 2'!(-quot;$P<H-(5/0 $$!quot;#$6quot;-#=%!!.1'()quot;6B7quot;*C $$$$2%7=;'00quot;;)$L:6)(##LF$J;'0)1'--quot;1$,K$L)9/056L $$quot;0! quot;0! O;)/'0I'0)1'--quot;1JJ?'()/05JJ?'()quot;6=!1%8$!'$+2%7+ $$3$<'(1$%77$1'()quot;6=== $$P<H-(5/0=%!!.1'()quot;6B2%7C $$3$quot;);=== quot;0!
  • 27. what’s missing?
  • 28. public assets
  • 29. copy
  • 30. file clash
  • 31. 83+!5*$+,#-&#-%'quot;$$.!) 2<./2%5quot;6$,$H%)90%2quot;=0quot;8B@/-quot;=!/10%2quot;B..@QR4..CC$S$ $$$$$$$$$$$$$$L%66quot;)6:/2%5quot;6L )%15quot;)$,$?%/-6=1'')$S$L7(&-/;:/2%5quot;6:2<.7-(5/0L @/-quot;T)/-6=2U!/1.7B)%15quot;)C 2<./2%5quot;6=;9/-!1quot;0=quot;%;9$!'$+quot;+$ $$$$@/-quot;T)/-6=;7.1Bquot;F$)%15quot;)$S$quot;=&%6quot;0%2quot;C$ quot;0!
  • 32. 83+!5*$+,#-&#-%'quot;$$.!) 2<./2%5quot;6$,$H%)90%2quot;=0quot;8B@/-quot;=!/10%2quot;B..@QR4..CC$S$ $$$$$$$$$$$$$$L%66quot;)6:/2%5quot;6L )%15quot;)$,$?%/-6=1'')$S$L7(&-/;:/2%5quot;6:2<.7-(5/0L )%15quot;)=2%Uquot;.6<2-/0UB2<./2%5quot;6C$(0-quot;66$)%15quot;)=quot;A/6)>
  • 33. migrations
  • 34. simple DSL
  • 35. rollback
  • 36. !&:2/51%)quot;: version $$VWWXWYWYYVYVZ[.%-79%=1& VWWXWYWVY[VZ[.&quot;)%=1& 20090101121234 20090102142345 7-(5/0:!&:2/51%)quot;: 2008123123456 $$VWW]YVZYZ[^.5%22%=1&
  • 37. 1%Uquot;$!&J1'--&%;U version P/51%)'1=1'--&%;U 20090101121234 P/51%)'13;(11quot;0).Dquot;16/'0 20090102142345 P/51%)'132/51%)quot;!=-%6) 2008123123456 P/51%)'1=5quot;).%--.Dquot;16/'06 BL_4R4I`$Dquot;16/'0$@?aP$$ $$6;9quot;2%.2/51%)/'06LC =2%7BbJ)'./C=6'1)
  • 38. it gets worse
  • 39. !&:2/51%)quot;: version $$WWY.%-79%=1& WWV.&quot;)%=1& 001 002 7-(5/0:!&:2/51%)quot;: $$WWY.5%22%=1&
  • 40. http://www.flickr.com/photos/bk2204/475332962/
  • 41. single timeline
  • 42. You 1 n tio n1 ra tio ig gra m pp mi a n2 in ug tio l p gra 3 i ion m Me at pp igr a all pm ra nst p ig a i nm gi plu de ra pg u
  • 43. n1 tio You gra n1 i tio m gra pp mi a n2 gin tio plu ra n3 ig pm tio ra ap n2 ig tio pm gra ap mi gin plu
  • 44. !&:2/51%)quot;: $$WWY.%-79%=1& WWV.&quot;)%=1& WWZ.7-(5/0.)'.WWY=1& WW[.!quot;-)%=1& 7-(5/0:!&:2/51%)quot;: $$WWY.5%22%=1&
  • 45. Symlink? !&:2/51%)quot;: $$WWY.%-79%=1& WWV.&quot;)%=1& Reference? WWZ.7-(5/0.)'.WWY=1& WW[.!quot;-)%=1& Copy & 7-(5/0:!&:2/51%)quot;: Retimestamp? $$WWY.5%22%=1&
  • 46. Ticket #2058 interblah.net/plugin-migrations
  • 47. my recommendation? (for the moment, at least)
  • 48. write a generator (within your plugin) c$6;1/7):5quot;0quot;1%)quot;$%;)6.%6.#(.2/51%)/'06 $$$$ $$$quot;A/6)6$$!&:2/51%)quot; $$$;1quot;%)quot;$$!&:2/51%)quot;:VWWXWWYYYZZd.&-%9=1& c$===
  • 49. techniques
  • 50. overriding functionality
  • 51. views just work
  • 52. controllers
  • 53. straight override
  • 54. module
  • 55. namespaced
  • 56. playing nice with the class cache
  • 57. 1/23*8/36/1**$#2quot;'#3-43-'!3$$(!/ ! 9quot;%/)((-/!(73:(;/6!37/'9(/73;+$(/ < < '!((/)+'/#%/%'#$$/quot;2'#:(<< < < <<
  • 58. O;)/Dquot;_(77'1)JJequot;7quot;0!quot;0;/quot;6=-'%!.'0;quot;.7%)96
  • 59. ApplicationController AppController PluginController
  • 60. ApplicationController PluginController
  • 61. 23-6#,&(-:#!3-7(-'.!) ?%/-6JJQ0/)/%-/fquot;1=1(0$!'$+;'0#/5+ $$3$quot;);=== $$;'0#/5=1quot;-'%!.7-(5/06$,$)1(quot; $$ quot;0!
  • 62. 83+!5*$+,#-&quot;**&23-'!3$$(!%&,33;523-'!3$$(!.!) ;-%66$g''!I'0)1'--quot;1$h$=== $$(0-'%!%&-quot; $$ $$3$quot;);$=== quot;0!
  • 63. init.rb woes
  • 64. 785*$+,#-&#-#'.!) ;'0#/5=)'.71quot;7%1quot;$!' $$_'2quot;O77I-%66=quot;A)quot;0!BP<iquot;9%D/'(1C $$ quot;0!
  • 65. testing
  • 66. ApplicationController AppController PluginController
  • 67. ApplicationController ode ir C The Code Your PluginController
  • 68. quot; $ ! #
  • 69. unit test?
  • 70. test in your own rails environment?
  • 71. plugin_test_helper
  • 72. I care about testing my chunk
  • 73. You care about testing your whole app
  • 74. empower the developer
  • 75. avoiding fail
  • 76. ;%6quot;$;'!quot;=;'06(2quot;1 $$89quot;0$;'!quot;=%()9'1 $$$$1quot;(6quot;=2'6)-<$,j$:quot;##quot;;)/Dquot;: $$89quot;0$1%0!B!quot;Dquot;-'7quot;1C $$$$1quot;(6quot;=)1/;U/quot;1.&().7'66/&-quot;B)1(quot;C $$quot;-6quot; $$$$1quot;(6quot;='Dquot;11%)quot;!N quot;0!
  • 77. consume wisely
  • 78. Nutrition Facts Serving Size 14 kloc Amount Per Serving 1 bad engine Calories 10,666 % Daily Value* Total Fat 2674g 98% 34% Long Methods 1578g 7% God Objects 326g Stress 320mg 119% Hairloss 45g 45.8% Technical Debt 13g 87% Untested Code 1578mg 34% 7% Hidden Bugs 326mg Benefit 1mg 0.1%
  • 79. you will not be able to write some engines.
  • 80. you will not be able to use some engines.
  • 81. extract specific functionality
  • 82. establish some clear integration points
  • 83. you are customer #1
  • 84. READ the CODE
  • 85. james@lazyatom.com FIN lets@gofreerange.com