Git Driven Refactoring

Git Driven Refactoring

Often we know that our code needs refactoring, but we have no idea where to start. Maybe we studied some common code smells and learned about the things that we should be avoiding, but memorizing the rules doesn’t automatically lead to fixing all problems. In this talk, we explore how you can use Git to recognize and address violations to each of the SOLID principles. Using diffs, commit history and pull requests you can learn to recognize patterns in code that point to problems. These same tools can help you correct those issues and write more maintainable code.

B9723dc81eafa0294ce0a5e33a1fc584?s=128

Ashley Ellis Pierce

November 15, 2017
Tweet

Transcript

  1. 9.
  2. 24.
  3. 25.
  4. 26.
  5. 27.
  6. 28.
  7. 30.
  8. 34.
  9. 36.
  10. 38.
  11. 39.
  12. 40.
  13. 41.
  14. 42.
  15. 43.
  16. 44.
  17. 49.
  18. 56.
  19. 58.
  20. 59.
  21. 62.
  22. 64.
  23. 67.

    You should be able to call the same method on

    a subclass as you could on a parent and get a compatible result
  24. 68.
  25. 69.
  26. 71.
  27. 73.
  28. 76.
  29. 77.
  30. 78.
  31. 79.
  32. 82.
  33. 83.
  34. 85.
  35. 86.
  36. 87.
  37. 88.
  38. 89.
  39. 90.
  40. 91.
  41. 92.
  42. 93.
  43. 101.
  44. 102.
  45. 103.
  46. 104.
  47. 105.
  48. 107.

    Use the git log to group commits into topics and

    recognize when a class is doing more than one thing
  49. 108.

    Keep an eye out for red in the diff when

    you're adding functionality, this could indicate a violation of the Open/Closed principle
  50. 109.

    Integrate tools like automatic style linters with your GitHub account

    to make code cleaner and easier to recognize problems
  51. 110.

    Use git log and git blame to find how often

    classes or methods have had to change. This tells you where your worst offenders most in need of refactor are.
  52. 112.