1 / 11

Refactoring Legacy Code

Refactoring Legacy Code. Andreas Enbohm @ enbohm 2013-09-11. About Me. What is Legacy Code ?. Legacy Code. Legacy Code is Simply Code Without Tests! (do you write legacy code ?). Refactoring. Sandro Mancuso http://craftedsw.blogspot.com. Refactoring Legacy Code.

delila
Télécharger la présentation

Refactoring Legacy Code

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Refactoring Legacy Code Andreas Enbohm @enbohm 2013-09-11

  2. About Me

  3. What is LegacyCode?

  4. LegacyCode LegacyCode is SimplyCodeWithout Tests! (do youwritelegacycode?)

  5. Refactoring Sandro Mancuso http://craftedsw.blogspot.com

  6. RefactoringLegacyCode • Have a cleargoal- otherwise you couldend up just movingaroundcode and not makingthingsanybetter • Specify, don’tverify- aim is not to test code, but to produceartifacts that describesitsbehaviour (characterization tests)

  7. Business ComponentWeWant to Change TweetService.java– a service responsible for finding tweets by a specificuser • Need to be logged in to seetweets by a particularuser • Need to be friends to seesomeoneelse’stweets

  8. Tips • Use a codecoveragetool • Commitoften- enables you to commitimprovementsquickly- allows you to rollback if you make a mistake- remember, refactoringshould be done in small steps! • IdentifySeams- parts whereyoucanmodifybehaviourwithoutediting that place- useknowndependencybreakingtechniques to createseams • Stay in the ’green-zone’ as long as possible

  9. Tips (cont) Start refactoring from deepest to shortestbranch if (…) { booleanparam… if (param) { if (getStuff()) { … } } } else { … } Start testing from shortest to deepestbranch

  10. Q & A http://www.slideshare.net/enbohm @enbohm https://github.com/enbohm

More Related