-
메소드 정리 : Inline TempProgramming/리팩토링 2020. 9. 4. 15:27
참고자료
http://refactoring.guru/inline-temp
Inline Temp
Tired of reading? No wonder, it takes 7 hours to read all of the text we have here. Try our interactive course on refactoring. It offers a less tedious approach to learning new stuff. Let's see...
refactoring.guru
정의
간단한 수식의 결과값을 가지는 임시 변수가 있고, 그 임시변수가 리팩토링을 하는데 방해가 된다면,
임시변수를 잠조하는 부분을 원래의 수식으로 바꾸는 작업이다.
기존 예시
boolean hasDiscount(Order order) { double basePrice = order.basePrice(); return basePrice > 1000; }
리팩토링 예시
boolean hasDiscount(Order order) { return order.basePrice() > 1000; }
반응형'Programming > 리팩토링' 카테고리의 다른 글
메소드 정리 : Remove Assignments to Parameters (0) 2020.09.04 메소드 정리 : Split Temporary Variable (0) 2020.09.04 메소드 정리 : Replace Temp with Query (0) 2020.09.04 메소드 정리 : Inline Method (0) 2020.09.04 메소드 정리 : Extract Method (0) 2020.09.04