how to avoid if conditions,
Posted
by kumar kasimala
on Stack Overflow
See other posts from Stack Overflow
or by kumar kasimala
Published on 2010-05-05T10:21:43Z
Indexed on
2010/05/05
10:28 UTC
Read the original article
Hit count: 230
Hi all,
can anyone suggest best way to avoid most if conditions? I have below code, I want avoid most of cases if conditions, how to do it ? any solution is great help;
if (adjustment.adjustmentAccount.isIncrease) {
if (adjustment.increaseVATLine) {
if (adjustment.vatItem.isSalesType) {
entry2.setDebit(adjustment.total);
entry2.setCredit(0d);
} else {
entry2.setCredit(adjustment.total);
entry2.setDebit(0d);
}
} else {
if (adjustment.vatItem.isSalesType) {
entry2.setCredit(adjustment.total);
entry2.setDebit(0d);
} else {
entry2.setDebit(adjustment.total);
entry2.setCredit(0d);
}
}
} else {
if (adjustment.increaseVATLine) {
if (adjustment.vatItem.isSalesType) {
entry2.setCredit(adjustment.total);
entry2.setDebit(0d);
} else {
entry2.setDebit(adjustment.total);
entry2.setCredit(0d);
}
} else {
if (adjustment.vatItem.isSalesType) {
entry2.setDebit(adjustment.total);
entry2.setCredit(0d);
} else {
entry2.setCredit(adjustment.total);
entry2.setDebit(0d);
}
}
© Stack Overflow or respective owner