Your SlideShare is downloading. ×
Refactoring - An Introduction
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Refactoring - An Introduction

5,998
views

Published on

A brief introduction to the agile practice of Refactoring

A brief introduction to the agile practice of Refactoring

Published in: Technology, News & Politics

10 Comments
54 Likes
Statistics
Notes
No Downloads
Views
Total Views
5,998
On Slideshare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
0
Comments
10
Likes
54
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Refactoring An Introduction Giorgio Vespucci
  • 2. “Software must be soft: it has to be easy to change because it will change despite our misguided efforts otherwise.” The Pragmatic Programmers
  • 3. What we want Robustness Simplicity Softness
  • 4. What we see Fragility Complexity Rigidity
  • 5. Unreadable code is…
  • 6. Hard to modify
  • 7. Duplicated code is…
  • 8. Hard to modify
  • 9. Complex code is…
  • 10. Hard to modify
  • 11. Refactored code is...
  • 12. Easier to understand
  • 13. Cheaper to modify
  • 14. Clean code
  • 15. Better code
  • 16. Refactored code shows...
  • 17. Changes to its internal structure
  • 18. But no change to observable behavior
  • 19. “So what?”
  • 20. Try to understand this Java code
  • 21. java.util.Calendar c =  java.util.Calendar.getInstance(); c.set(2005, java.util.Calendar.NOVEMBER, 20); c.getTime();
  • 22. Uhm... a Date...
  • 23. And now this code
  • 24. october(23,2008);
  • 25. Hey, mum! It's a Date!
  • 26. “Any fool can write code that a computer can understand.”
  • 27. “Good programmers write code that humans can understand.” Martin Fowler - Refactoring
  • 28. What do we need ?
  • 29. “If you want to refactor, the essential precondition is having solid tests.” Martin Fowler - Refactoring
  • 30. Measures matter
  • 31. Where to start ?
  • 32. Look at the code
  • 33. Sniff the code
  • 34. Does it smell ?
  • 35. Duupliccateed code? Loooooong method? L a r g e class?
  • 36. The Refactoring cycle 1) Choose the worst smell 2) Select a refactoring 3) Apply the refactoring 4) Run all the tests
  • 37. little steps
  • 38. Great results
  • 39. Must-have books on Refactoring Refactoring: Improving the Design of Existing Code (Addison-Wesley Object Technology Series) Martin Fowler Refactoring Workbook (Addison-Wesley Object Technology Series) William C. Wake Refactoring to Patterns (Addison-Wesley Signature Series) Joshua Kerievsky
  • 40. Online resources Smells to refactor http://wiki.java.net/bin/view/People/SmellsToRefactorings Alpha list of refactoring http://www.refactoring.com/catalog/index.html Refactoring Workbook Website http://xp123.com/rwb/ Refactoring to Patterns catalog http://industriallogic.com/xp/refactoring/catalog.html