Legacy code rehab
-
Upload
johnnonolan -
Category
Technology
-
view
101 -
download
1
Transcript of Legacy code rehab
Legacy Code : Rehab
A Workshop with @johnnonolan
Friday, 26 April 13
• Spent a few years thinking about rewrites.
• Not an expert/guru.
• Written a load of crap.
Me
Friday, 26 April 13
What is legacy?• Code without tests?
• Old tech?
• Not the latest thing?
• Not invented here?
Friday, 26 April 13
Is legacy so bad?Outside of software, how do we see legacy?
Friday, 26 April 13
Theres no getting away with it
Legacy is everywhere
Friday, 26 April 13
2 choices
Rebuild or RenovatePhoto by John T Pilot
Friday, 26 April 13
• Estimates always wrong.
• New bugs.
• Secret knowledge in the code.
• Lengthy code freeze.
• Organisation needs to wait for new features.
Risks of Re-building
Friday, 26 April 13
But Renovating?• The code is a mess.
• You don't know where to start.
• It has become poorly designed.
• It is typically untested.
Friday, 26 April 13
Botch it then?• Just hack the change in.
• Code will be worse.
• Which leads to worse code.
Friday, 26 April 13
Right let's do it!• Scratch refactor
• Tell the story of the system
• Sketches
• Characterization tests
• Golden Master technique
Friday, 26 April 13
Code SampleTrivia Code base
https://github.com/jbrains/trivia
Friday, 26 April 13
Scratch refactor• Start playing with the code.
• Throw away the changes.
Friday, 26 April 13
Telling the story?• Just the essentials
• Then move on to more granular bits
• Rinse & repeat.
Friday, 26 April 13
Sketches• Feature sketches
• Effect Sketches
• Effect analysis
Friday, 26 April 13
Characterization tests• Fail
• Pass
• Sensing variables
• Inheritance
• change access modifier
• Throwaway?
Friday, 26 April 13
New Feature
Friday, 26 April 13
Thanks• This session is all about understanding the impact of
change.
• Small safe steps.
• Vices.
Friday, 26 April 13