-
리팩토링 : Decompose Conditional리팩토링 2012. 12. 7. 09:30
조건 :
복잡한 (if - then -else) 조건문을 가지고 있다면
적용 :
조건부분, then부분, else부분을 메소드로 뽑아내라.
적용전
if (date.before (SUMMER_START) || date.after(SUMMER_END)) charge = quantity * _winterRate + _winterServiceCharge; else charge = quantity * _summerRate;
적용후
if (notSummer(date)) charge = winterCharge(quantity); else charge = summerCharge (quantity);
참조 :
http://www.refactoring.com/catalog/decomposeConditional.html
'리팩토링' 카테고리의 다른 글
리팩토링 : Eliminate Inter-Entity Bean Communication (0) 2012.12.11 리팩토링 : Duplicate Observed Data (0) 2012.12.08 리팩토링 : Convert Static to Dynamic Construction (0) 2012.12.06 리팩토링 : Convert Dynamic to Static Construction (0) 2012.12.05 리팩토링 : Consolidate Duplicate Conditional Fragments (0) 2012.12.04 댓글