Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up
for free
Working With Legacy Rails Apps
Ahmed Omran
July 10, 2015
Programming
0
51
Working With Legacy Rails Apps
Ahmed Omran
July 10, 2015
Tweet
Share
More Decks by Ahmed Omran
See All by Ahmed Omran
this_ahmed
2
110
this_ahmed
1
91
this_ahmed
0
25
this_ahmed
4
4.7k
Other Decks in Programming
See All in Programming
makomakok
1
250
boriswilhelms
0
120
deepflow
9
3.1k
ryokbt
2
290
martysuzuki
1
400
legalforce
PRO
0
630
saten
1
180
christianliebel
PRO
0
140
heistak
2
130
grapecity_dev
1
190
grapecity_dev
0
170
aftiopk
0
110
Featured
See All Featured
denniskardys
219
120k
philnash
9
580
brettharned
93
3k
dougneiner
55
5.4k
robhawkes
52
2.8k
destraynor
146
19k
deanohume
294
28k
morganepeng
18
1.2k
maggiecrowley
10
500
lara
172
9.6k
tmm1
61
9.3k
tanoku
258
24k
Transcript
Working With Legacy Rails Apps @this_ahmed
Working With Legacy Rails Apps @this_ahmed
legacy code • untested code (Michael C. Feathers) • code
someone else wrote (old gems, outsourcing, maintainers left) • difficult to work with • risky to change • but serves a useful function
googling legacy code …
every project has legacy code?
None
• learning & experimenting • ambitious applications • big project,
developer churn, hiring outside help • bad code … even with the best of intentions • “Technical debt”
None
–Robert C. Martin “Even the most disciplined development team, knowing
the best principles, using the best patterns, and following the best practices will create messes from time to time.”
in the face of legacy code you can …
None
or…
None
Useful techniques
Rebuild Refactor
–Robert C. Martin “…taking a tangled, opaque, convoluted system and
slowly, gradually, piece by piece, step by step, turning it into a simple, nicely structured, well-designed system.”
Boy Scout Rule Clean up around you work area. Small
fixes; small refractors.
cover and modify • add unit test • test passes
• modify code • test passes
use mock objects to break dependencies
None
mock dependencies
break complicated dependencies with seams
None
seam => put in method + stub
first step to later refactor
i don’t understand this code…
Ask someone
code archeology
code archeology git blame / Github
code archeology search code for context git blame / Github
code archeology project management ticket git blame / Github search
code for context
code archeology git blame / Github project management ticket commit
message search code for context
review • boy scout rule • cover and modify •
break dependencies with mocks and seams • understand code with archeology
some parting thoughts
unit test
None
None
• code review • small git branches • add lots
of context in pull request / commit message