Automated Refactoring
-
Upload
janeve-george -
Category
Technology
-
view
1.370 -
download
0
Transcript of Automated Refactoring
- 1. Code Smells And Automated Refactoring Janeve George [email_address] Amit Goyal [email_address] Presented By:
- 2. Few Instructions
- It's not a presentation !!!
- 3. Parking lot
- 4. Feedback stickies
- 5. Flow Of The Session
- The Problem
- 6. Code Refactoring
- 7. Automated Refactoring
- 8. Code Smells
- 9. Quiz
- 10. Refactoring Workshop
- 11. Flow Of The Session
- The Problem
- Code Refactoring
- 12. Automated Refactoring
- 13. Code Smells
- 14. Quiz
- 15. Refactoring Workshop
- 16. The Problem
- 17. Flow Of The Session
- The Problem
- 18. Code Refactoring
- Automated Refactoring
- 19. Code Smells
- 20. Quiz
- 21. Refactoring Workshop
- 22. Code Refactoring
- Series of small steps
- 23. Change in the internal structure
- 24. No change in the external behavior
- 25. java.util.Calendar c =java.util.Calendar.getInstance(); c.set(2010, java.util.Calendar.APRIL, 25); Date today = c.getTime();
- 26. Date today = april(25, 2010);
- 27. double getPayAmount() { double result; if (_isDead) { // Get the dead amount result = getAmount1(); } else { if (_isSeparated)) { // Get the separated amount result = getAmount2(); } else { if (_isRetired) { // Get the retired amount result = getAmount3(); } else { // Get the normal amount result = getAmount4(); } } } return result; }
- 28. double getPayAmount() { if (_isDead) return deadAmount(); if (_isSeparated) returnseparatedAmount(); if (_isRetired) return retiredAmount(); return normalPayment(); }
- 29. Flow Of The Session
- The Problem
- 30. Code Refactoring
- 31. Automated Refactoring
- Code Smells
- 32. Quiz
- 33. Refactoring Workshop
- 34. Automated Refactoring
- 35. Flow Of The Session
- The Problem
- 36. Code Refactoring
- 37. Automated Refactoring
- 38. Code Smells
- Quiz
- 39. Refactoring Workshop
- 40. Code Smells
- Duplicated Code
- 41. Long Method
- 42. Large Class
- 43. Switch Statements
- 44. Feature Envy
- 45. Magic Number
- 46. Comments
- 47. Improper Name
- 48. & Many More....
- 49. Duplicate Code
- 50. Long Method
- 51. Large Class
- 52. Switch Statements
- 53. Feature Envy
- 54. Magic Numbers
- 55. Comments
- 56. Improper Naming
- 57. Flow Of The Session
- The Problem
- 58. Code Refactoring
- 59. Automated Refactoring
- 60. Code Smells
- 61. Quiz
- Refactoring Workshop
- 63. if( isSpecialDeal() ) { total = price * 0.95; send(); } else { total = price * 0.98; send(); } Identify code smells in the following code snippet and suggest remedies:
- 64. Refactor the following code: int d;//elapsed time in days
- 65. What are the remedies to deal with a large class?
- 66. Refactoring helps in __________, ___________, __________.
- 67. double potentialEnergy(double mass, double height) { return mass * 9.81 * height; } Identify code smells in the following code snippet:
- 68. Large class violates _____________ principle.
- 69. What are the techniques/remedies to deal with a long method?
- 70.
- make it loosely coupled
- 71. improve code readability
- 72. make it simple
- 73. Duplicate code violates ___________ principle.
- 74. void printOwning(double amount) { printBanner(); //Print details System.out.println("name"+ _name); System.out.println("amount" + amount); } Identify code smells in the following code snippet and suggest remedies:
- 75. //Calculate perimeter double temp = 2 * (_height + _width); Refactor the following code:
- 76. double disabilityAmount() { if( _seniority < 2 ) return 0; if( _monthsDisabled > 12 ) return 0; if( _isPartTime) return 0; ..... ..... } Refactor the following code:
- 77. Flow Of The Session
- The Problem
- 78. Code Refactoring
- 79. Automated Refactoring
- 80. Code Smells
- 81. Quiz
- 82. Refactoring Workshop
- 85. References
- 86. [email_address] [email_address]