-
Notifications
You must be signed in to change notification settings - Fork 1
Functions
Alex Aubé edited this page Apr 22, 2015
·
4 revisions
- Divide the code => Use small functions, private functions, don't use comments to explain easy stuff.
- For readability and to code reuse
- Code should be read like a story
- Smells => Not fitting in a page, read twice to understand, vertical blocs...
public Paie genererPaie() {
double salaireBrut = calculerSalaireBrut();
double impot = calculerImpot(salaireBrut);
double rrq = calculerRrq(salaireBrut + impot);
double cumulatif = salaireBrut + impot + rrq;
return new Paie(salaireBrut, impot, rrq, cumulatif);
}
private double calculerSalaireBrut() {
double salaireBrut = 0;
for(PlageHoraire plage: getPlagesHoraires())
salaireBrut += plage.getHeures() * getTauxHoraire();
}
private double calculerImpot(double salaireBrut) {
return salaireBrut * employe.getTauxImpot();
}
private calculerRrq(double cumulatif) {
return cumulatif * getTauxRrq();
}