Refactoring

807 views

Published on

Published in: Education
0 Comments
3 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
807
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
13
Comments
0
Likes
3
Embeds 0
No embeds

No notes for slide

Refactoring

  1. 1. Any fool can write code that computer can understand. Good programmers write code that humans can understand. Martin Fowler - Refactoring
  2. 2. Calendar c = Calendar.getInstance(); c.set(2005, Calendar.NOVEMBER, 20); c.getTime(); november(20, 2005);
  3. 3. bug
  4. 4. • • • •
  5. 5. OCP (Open-Closed Principle)
  6. 6. DRY (Don’t Repeat Yourself)
  7. 7. SRP (Single Responsibility Principle)
  8. 8. LSP (Liskov Substitution Principle)
  9. 9. (duplicated code)
  10. 10. (long method)
  11. 11. (large class)
  12. 12. (long parameter list)
  13. 13. (divergent change) class
  14. 14. (shotgun surgery) classes
  15. 15. (feature envy)
  16. 16. (primitive obsession)
  17. 17. switch (switch statements)
  18. 18. (lazy class)
  19. 19. (speculative generality)
  20. 20. (data class)
  21. 21. (refused bequest)
  22. 22. (comments)
  23. 23. (Extract Method) Eclipse✔
  24. 24. (Inline Method) Eclipse✔
  25. 25. (Inline Temp) Eclipse✔
  26. 26. (Replace Temp with Query) Eclipse✘
  27. 27. (Introduce Explaining Variable) Eclipse✔
  28. 28. (Split Temporary Variable) Eclipse✘
  29. 29. Remove Assignments to Parameters Eclipse✘
  30. 30. (Move Method) Eclipse✔
  31. 31. (Move Field) Eclipse✔
  32. 32. (Extract Class) Eclipse✔
  33. 33. (Replace Data Value with Object) Eclipse✘
  34. 34. (Replace Magic Number with Symbolic Constant) Eclipse✔
  35. 35. (Encapsulate Collection) Eclipse✘
  36. 36. (Replace Type Code with Class) Eclipse✘
  37. 37. (Replace Type Code with Subclasses) Eclipse✘
  38. 38. State/Strategy (Replace Type Code with State/ Strategy) Eclipse✘
  39. 39. (Decompose Conditional) Eclipse✔ (Use Extract Method)
  40. 40. (Consolidate Conditional Expression) Eclipse✔
  41. 41. (Consolidate Duplicate Conditional Fragments) Eclipse✘
  42. 42. (Replace Nested Conditional with Guard Clauses) Eclipse✘
  43. 43. (Replace Conditional with Polymorphism) Eclipse✘
  44. 44. null (Introduce Null Object) Eclipse✘
  45. 45. (Rename Method) Eclipse✔
  46. 46. (Add Parameter) Eclipse✔
  47. 47. (Remove Parameter) Eclipse✔
  48. 48. (Separate Query from Modifier) Eclipse✔ (extract two methods and rename)
  49. 49. (Parameterize Method) Eclipse✘
  50. 50. (Preserve Whole Object) Eclipse✘
  51. 51. (Introduce Parameter Object) Eclipse✔
  52. 52. More…
  53. 53. One more thing…

×