改善既有的代码-重构(ppt)-课件.pptVIP

  • 307
  • 0
  • 约7.15千字
  • 约 40页
  • 2018-10-16 发布于湖北
  • 举报
改善既有的代码-重构(ppt)-课件

简化条件表达式 double getPayAmount() { double result; if (_isDead) result = deadAmount(); else { if (_isSeparated) result = separatedAmount(); else { if (_isRetired) result = retiredAmount(); else result = normalPayAmount(); }; }     return result; }; double getPayAmount() { if (_isDead) return deadAmount(); if (_isSeparated) return separatedAmount(); if (_isRetired) return retiredAmount(); return normalPayAmount(); }; Split Loop - 1 void printValues() { double averageAge = 0; double totalSalary = 0; for (int i = 0; i people.length; i++) { averageAge += people[i].age; totalSal

文档评论(0)

1亿VIP精品文档

相关文档