-
메소드 정리 : Remove Assignments to ParametersProgramming/리팩토링 2020. 9. 4. 16:20
참고자료
http://refactoring.guru/remove-assignments-to-parameters
Remove Assignments to Parameters
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
정의
파라미터에 값을 할당하는 코드가 있으면, 파라미터를 바로 사용하기보단 임수변수에 저장하여 사용하도록 권고한다.
예시
int discount(int inputVal, int quantity) { if (inputVal > 50) { inputVal -= 2; } // ... }
리팩토링 예시
int discount(int inputVal, int quantity) { int result = inputVal; if (inputVal > 50) { result -= 2; } // ... }
반응형'Programming > 리팩토링' 카테고리의 다른 글
객체 간 기능 이동 : Move Method, Move Field (0) 2020.09.05 메소드 정리 : Replace Method with Method Object (0) 2020.09.04 메소드 정리 : Split Temporary Variable (0) 2020.09.04 메소드 정리 : Replace Temp with Query (0) 2020.09.04 메소드 정리 : Inline Temp (0) 2020.09.04