Legacy code rehab.


Published on

Presented at Chester Devs 06/02/2013

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Legacy code rehab.

  1. 1. L egacy Cod e : Rehab lanA Workshop with @johnnono
  2. 2. Me● Spent a few years thinking about rewrites.● Not an expert/guru.● Written a load of crap.
  3. 3. What is legacy?● Code without tests?● Old tech?● Not the latest thing?● Not invented here?
  4. 4. Is lega cy so bad?Outside of software, how do we see legacy?
  5. 5. getting aw ay with itTheres no Legacy is everywhere
  6. 6. 2 choices Photo by John T PilotRebuild or Renovate
  7. 7. Risks of R e-building● Estimates always wrong.● New bugs.● Secret knowledge in the code.● Lengthy code freeze.● Organisation needs to wait for new features.
  8. 8. But Renovating?● The code is a mess.● You dont know where to start.● It has become poorly designed.● It is typically untested.
  9. 9. Bot ch it then?● Just hack the change in.● Code will be worse.● Which leads to worse code.
  10. 10. Right lets do it!● Scratch refactor● Tell the story of the system● Sketches● Characterization tests
  11. 11. Cod e SampleTrivia Code basehttps://github.com/jbrains/trivia
  12. 12. Scratch refactor● Start playing with the code.● Throw away the changes.
  13. 13. Telling the story?● Just the essentials● Then move on to more granular bits● Rinse & repeat.
  14. 14. Sketches● Feature sketches● Effect Sketches● Effect analysis
  15. 15. C haracteriz ation tests● Fail● Pass● Sensing variables● Inheritance● change access modifier● Throwaway?
  16. 16. New Feature
  17. 17. Thanks● This session is all about understanding the impact of change.● Small safe steps.● Vices.
  18. 18. Feedback Email : johnnonolan@gmail.com Twitter: @johnnonolan