카탈로그 설명을 보기전에 어떻게 읽으면 좋은지 알아보자.
리팩터링 설명 형식
- 이름
- 개요: 핵심 개념이 무엇인가?
- 나중에 찾아볼 때, 이게 어떤건지 쉽게 떠올리기 위한 것.
- 배경: 이 기법이 왜 필요한가?
- 절차: 어떻게 처리하면 되는지에 대한 과정
- 리팩토링 단계를 작게 나누어 해야하는 지침들.
- 예시: 실제 코드를 보여준다.
- 처음에는 예시부터 보자.
- 그리고 예시는 매우 간단한 것으로 구성했다.
Basic Refactoring
- 12. Extract Function
- 13. Inline Function
- 14. Extract Variable
- 15. Inline Variable
- 16. Change Function Declaration
- 17. Encapsulate Variable
- 18. Rename Variable
- 19. Make Parameter Object
- 20. Combine Functions into Class
- 21. Combine Functions into Transform
- 22. Split Phase
Encapsulation
- 23. Encapsulate Record
- 24. Encapsulate Collection
- 25. Replace Primitive with Object
- 26. Replace Temp With Query
- 27. Extract Class
- 28. Inline Class
- 29. Hide Delegate
- 30. Remove Middle Man
- 31. Substitute Algorithm
Move Features
- 32. Move Function
- 33. Move Field
- 34. Move Statement into Function
- 35. Move Statements to Callers
- 36. Replace Inline Code With Function Call
- 37. Slide Statements
- 38. Split Loop
- 39. Replace Loop with Pipeline
- 40. Remove Dead Code
Data Organization
- 41. Spilt Variable
- 42. Rename Field
- 43. Replace Derived Variable With Query
- 44. Change Reference To Value
- 45. Change Value To Reference
Simplifying conditional logic
- 46. Decompose Conditional
- 47. Consolidate Conditional Expression
- 48. Replace Nested Conditional With Guard Clauses
- 49. Replace Conditional With Polymorphism
- 50. Introduce Special Case
- 51. Introduce Assertion
API Refactoring
- 52. Separate Query From Modifier
- 53. Parameterize Function
- 54. Remove Flag Argument
- 55. Preserve Whole Object
- 56. Replace Parameter With Query
- 57. Replace Query with Parameter
- 58. Remove Setting method
- 59. Replace Constructor with Factory Method
- 60. Replace Function with Command
- 61. Replace Command with Function
Dealing with Inheritance
- 62. Pull up Methods
- 63. Pull up Field
- 64. Pull up Constructor Body
- 65. Push down Method
- 66. Push down Field
- 67. Replace Type Code with SubClasses
- 68. Remove Subclass
- 69. Extract SuperClass
- 70. Collapse Hierarchy
- 71. Replace SubClass with Delegate
- 72. Replace SuperClass with Delegate