Created
September 24, 2016 00:02
-
-
Save abiodun0/b3cc301b4f3cffb2e0464b785f4b2afe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pay() { | |
for(var i = 0; i< employees.length; i++ ){ | |
if(employees[i].isPayDay()){ | |
let pay = employees[i].calculate(pay); | |
employees[i].deliverPay(pay); | |
} | |
} | |
} | |
// This particular piece of code does three things.. Refactoring | |
function pay() { | |
for(var i = 0; i< employees.length; i++ ){ | |
payIfNeccessary(employees[i]); | |
} | |
} | |
function payIfNecessary(employee) { | |
if (employee.isPayday()) calculateAndDeliverPay(employee); | |
} | |
function calculateAndDeliverPay(employee) { | |
pay = employee.calculatePay(); | |
employee.deliverPay(pay); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment