Slide 1

Slide 1 text

The Even-Darker Art of Rails Engines

Slide 2

Slide 2 text

@lazyatom

Slide 3

Slide 3 text

github.com/lazyatom/engines

Slide 4

Slide 4 text

Rails 2.3

Slide 5

Slide 5 text

history

Slide 6

Slide 6 text

November 2005

Slide 7

Slide 7 text

it’s distracting!

Slide 8

Slide 8 text

reuse is overrated!

Slide 9

Slide 9 text

Evil! Evil! Evil! Evil! Evil! Evil! Evil! Evil! Shit!

Slide 10

Slide 10 text

eek!

Slide 11

Slide 11 text

appable_plugins

Slide 12

Slide 12 text

desert

Slide 13

Slide 13 text

merb slices?

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

engines

Slide 16

Slide 16 text

!"#$%&!"#$'#(%&$#)&!"#$%&*$+,#-.!) !"#$%&'() $$*%&'()$++,$-'%!.%&'()./0#'12%)/'0 "0! 3$405/0"6$%1"$7-(5/06$8/)9$%0$%77:$!/1";)'1<= !"#$"05/0"> $$9%6.%77.!/1";)'1<> "0! 3$?")(106$)1("$/#$)9"$"05/0"$69/76$8/)9$%$1'()/05$#/-" !"#$1'()"!> $$@/-"="A/6)>B1'()/05.#/-"C "0! !"#$D/"8.7%)9 $$@/-"=E'/0B!/1";)'1

Slide 17

Slide 17 text

app/controllers/ models/ helpers/ views/ metal/

Slide 18

Slide 18 text

*$+,#-&"**&23-'!3$$(!&*$+,#-523-'!3$$(!.!) ;-%66$H-(5/0I'0)1'--"1/0/1**$#2"'#3-43-'!3$$(! $$!"#$/0!"A $$$$1"0!"1$J)"A)$,K$LM"--'F$H-(5/0NL $$"0! "0!

Slide 19

Slide 19 text

9"-7"1$J%-- won’t load from your plugin

Slide 20

Slide 20 text

Ticket #1905

Slide 21

Slide 21 text

config/routes.rb

Slide 22

Slide 22 text

O;)/'0I'0)1'--"1JJ?'()/05JJ?'()"6=!1%8$!'$+2%7+ $$2%7=;'00";)$G:7%)9GF$J;'0)1'--"1$,K$L7-(5/0LF$ $$$$$$$$$$$$$$$$$$$$$$$J%;)/'0$,K$L/0!"AL "0! *$+,#-&23-6#,&!3+'(%.!)

Slide 23

Slide 23 text

top precedence

Slide 24

Slide 24 text

O;)/'0I'0)1'--"1JJ?'()/05JJ?'()"6=!1%8$!'$+2%7+ $$2%7=;'00";)$G:7%)9GF$J;'0)1'--"1$,K$L7-(5/0LF$ $$$$$$$$$$$$$$$$$$$$$$$J%;)/'0$,K$L/0!"AL "0! O;)/'0I'0)1'--"1JJ?'()/05JJ?'()"6=!1%8$!'$+2%7+ $$3$===$')9"1$1'()"6$=== $$2%7=;'00";)$G:7%)9GF$J;'0)1'--"1$,K$L%77LF$ $$$$$$$$$$$$$$$$$$$$$$$J%;)/'0$,K$L/0!"AL $$3$===$')9"1$1'()"6$=== "0! in your plugin: in your app:

Slide 25

Slide 25 text

O;)/'0I'0)1'--"1JJ?'()/05JJ?'()"6=!1%8$!'$+2%7+ $$2%7=;'00";)$G:7%)9GF$J;'0)1'--"1$,K$L7-(5/0LF$ $$$$$$$$$$$$$$$$$$$$$$$J%;)/'0$,K$L/0!"AL "0! O;)/'0I'0)1'--"1JJ?'()/05JJ?'()"6=!1%8$!'$+2%7+ $$3$===$')9"1$1'()"6$=== $$2%7=;'00";)$G:7%)9GF$J;'0)1'--"1$,K$L%77LF$ $$$$$$$$$$$$$$$$$$$$$$$J%;)/'0$,K$L/0!"AL $$3$===$')9"1$1'()"6$=== "0! in your plugin: in your app:

Slide 26

Slide 26 text

Ticket #2592 (also Ticket #329)

Slide 27

Slide 27 text

785*$+,#-&$#)&785*$+,#-.!) 2'!(-"$P

Slide 28

Slide 28 text

what’s missing?

Slide 29

Slide 29 text

public assets

Slide 30

Slide 30 text

copy

Slide 31

Slide 31 text

file clash

Slide 32

Slide 32 text

83+!5*$+,#--%'"$$.!) 2<./2%5"6$,$H%)90%2"=0"8B@/-"=!/10%2"B..@QR4..CC$S$ $$$$$$$$$$$$$$L%66")6:/2%5"6L )%15")$,$?%/-6=1'')$S$L7(&-/;:/2%5"6:2<.7-(5/0L @/-"T)/-6=2U!/1.7B)%15")C 2<./2%5"6=;9/-!1"0="%;9$!'$+"+$ $$$$@/-"T)/-6=;7.1B"F$)%15")$S$"=&%6"0%2"C$ "0!

Slide 33

Slide 33 text

83+!5*$+,#--%'"$$.!) 2<./2%5"6$,$H%)90%2"=0"8B@/-"=!/10%2"B..@QR4..CC$S$ $$$$$$$$$$$$$$L%66")6:/2%5"6L )%15")$,$?%/-6=1'')$S$L7(&-/;:/2%5"6:2<.7-(5/0L )%15")=2%U".6<2-/0UB2<./2%5"6C$(0-"66$)%15")="A/6)>

Slide 34

Slide 34 text

migrations

Slide 35

Slide 35 text

simple DSL

Slide 36

Slide 36 text

rollback

Slide 37

Slide 37 text

!&:2/51%)": $$VWWXWYWYYVYVZ[.%-79%=1& version 20090101121234 20090102142345 2008123123456 VWWXWYWVY[VZ[\.&")%=1& 7-(5/0:!&:2/51%)": $$VWW]YVZYZ[\^.5%22%=1&

Slide 38

Slide 38 text

version 20090101121234 20090102142345 2008123123456 1%U"$!&J1'--&%;U P/51%)'1=1'--&%;U P/51%)'13;(11"0).D"16/'0 P/51%)'132/51%)"!=-%6) P/51%)'1=5").%--.D"16/'06 BL_4R4I`$D"16/'0$@?aP$ $ $ $$6;9"2%.2/51%)/'06LC =2%7BbJ)'./C=6'1)

Slide 39

Slide 39 text

it gets worse

Slide 40

Slide 40 text

!&:2/51%)": $$WWY.%-79%=1& version 001 002 WWV.&")%=1& 7-(5/0:!&:2/51%)": $$WWY.5%22%=1&

Slide 41

Slide 41 text

http://www.flickr.com/photos/bk2204/475332962/

Slide 42

Slide 42 text

single timeline

Slide 43

Slide 43 text

app migration 1 app migration 2 plugin migration 1 app migration 3 plugin migra install upgrade You Me

Slide 44

Slide 44 text

app migration 1 app migration 2 plugin migration 1 app migration 3 plugin migration 2 You

Slide 45

Slide 45 text

WW[.!"-)%=1& !&:2/51%)": $$WWY.%-79%=1& WWV.&")%=1& 7-(5/0:!&:2/51%)": $$WWY.5%22%=1& WWZ.7-(5/0.)'.WWY=1&

Slide 46

Slide 46 text

WW[.!"-)%=1& !&:2/51%)": $$WWY.%-79%=1& WWV.&")%=1& 7-(5/0:!&:2/51%)": $$WWY.5%22%=1& WWZ.7-(5/0.)'.WWY=1& Copy & Retimestamp? Reference? Symlink?

Slide 47

Slide 47 text

Ticket #2058 interblah.net/plugin-migrations

Slide 48

Slide 48 text

my recommendation? (for the moment, at least)

Slide 49

Slide 49 text

write a generator c$6;1/7):5"0"1%)"$%;)6.%6.#(.2/51%)/'06 $$$$ $$$"A/6)6$$!&:2/51%)" $$$;1"%)"$$!&:2/51%)":VWWXW\W\YYYZZd.&-%9=1& c$=== (within your plugin)

Slide 50

Slide 50 text

techniques

Slide 51

Slide 51 text

overriding functionality

Slide 52

Slide 52 text

views just work

Slide 53

Slide 53 text

controllers

Slide 54

Slide 54 text

straight override

Slide 55

Slide 55 text

No content

Slide 56

Slide 56 text

No content

Slide 57

Slide 57 text

module

Slide 58

Slide 58 text

No content

Slide 59

Slide 59 text

No content

Slide 60

Slide 60 text

No content

Slide 61

Slide 61 text

namespaced

Slide 62

Slide 62 text

No content

Slide 63

Slide 63 text

No content

Slide 64

Slide 64 text

No content

Slide 65

Slide 65 text

playing nice with the class cache

Slide 66

Slide 66 text

1/23*8/36/1**$#2"'#3-43-'!3$$(!/ 9"%/)((-/!(73:(;/6!37/'9(/73;+$(/ '!((/)+'/#%/%'#$$/"2'#:(<< < < < < < < !

Slide 67

Slide 67 text

O;)/D"_(77'1)JJe"7"0!"0;/"6=-'%!.'0;".7%)96

Slide 68

Slide 68 text

ApplicationController AppController PluginController

Slide 69

Slide 69 text

ApplicationController PluginController

Slide 70

Slide 70 text

23-6#,&(-:#!3-7(-'.!) ?%/-6JJQ0/)/%-/f"1=1(0$!'$+;'0#/5+ $$3$");=== $$;'0#/5=1"-'%!.7-(5/06$,$)1(" $$ "0!

Slide 71

Slide 71 text

83+!5*$+,#-&"**&23-'!3$$(!%&,33;523-'!3$$(!.!) ;-%66$g''!I'0)1'--"1$h$=== $$(0-'%!%&-" $$ $$3$");$=== "0!

Slide 72

Slide 72 text

init.rb woes

Slide 73

Slide 73 text

;'0#/5=)'.71"7%1"$!' $$ "0! 785*$+,#--#'.!) $$_'2"O77I-%66="A)"0!BP

Slide 74

Slide 74 text

testing

Slide 75

Slide 75 text

ApplicationController PluginController AppController

Slide 76

Slide 76 text

ApplicationController PluginController Their Code Your Code

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

! " # $

Slide 79

Slide 79 text

No content

Slide 80

Slide 80 text

unit test?

Slide 81

Slide 81 text

test in your own rails environment?

Slide 82

Slide 82 text

plugin_test_helper

Slide 83

Slide 83 text

I care about testing my chunk

Slide 84

Slide 84 text

You care about testing your whole app

Slide 85

Slide 85 text

empower the developer

Slide 86

Slide 86 text

avoiding fail

Slide 87

Slide 87 text

;%6"$;'!"=;'06(2"1 $$89"0$;'!"=%()9'1 $$$$1"(6"=2'6)-<$,j$:"##";)/D": $$89"0$1%0!B!"D"-'7"1C $$$$1"(6"=)1/;U/"1.&().7'66/&-"B)1("C $$"-6" $$$$1"(6"='D"11%)"!N "0!

Slide 88

Slide 88 text

consume wisely

Slide 89

Slide 89 text

Serving Size 14 kloc Nutrition Facts Amount Per Serving 1 bad engine Calories 10,666 Long Methods 1578g 34% God Objects 326g 7% Stress 320mg 119% Total Fat 2674g 98% Hairloss 45g 45.8% % Daily Value* Technical Debt 13g 87% Untested Code 1578mg 34% Hidden Bugs 326mg 7% Benefit 1mg 0.1%

Slide 90

Slide 90 text

you will not be able to write some engines.

Slide 91

Slide 91 text

you will not be able to use some engines.

Slide 92

Slide 92 text

extract specific functionality

Slide 93

Slide 93 text

establish some clear integration points

Slide 94

Slide 94 text

you are customer #1

Slide 95

Slide 95 text

READ the CODE

Slide 96

Slide 96 text

james@lazyatom.com lets@gofreerange.com FIN