I was curious to anyone's thoughts, comments, and input as to something I was presented with during a job interview I went to recently. I was provided with some java code and asked to determine what was wrong with it and how bad it was. So, seeing as I didn't get the job I was curious what are the thoughts on the following code.
public void assessAdjustSuspendFJOffense(Long offID, Date nextDueDate, List fjList, List amountList, List reasonList, OverrideApprovalHolder ovrApprovalBean) {
Offense off = (Offense) getDom(offID, "Offense", Offense.class);
Assert.notNull(nextDueDate, "due date cannot be null");
Defendant def = (Defendant) off.getDefendant();
Person person = (Person) def.getEntity();
StandardAssetAccount accRcv = (StandardAssetAccount) accDao
.getStandardAccount(StandardAccount.ACCOUNT_RECEIVABLE);
StandardLiabilityAccount accDefPay = (StandardLiabilityAccount) accDao
.getStandardAccount(StandardAccount.DEFERRED_PAYABLE);
Iterator it = fjList.iterator();
for (int i = 0; i < fjList.size(); i++) {
FJOffense fjOff = (FJOffense) fjList.get(i);
AssessAdjustSuspendBean aas = (AssessAdjustSuspendBean) amountList.get(i);
Type reasonType = (Type) reasonList.get(i);
if (fjOff.getID() != null && aas.getAdjust().compareTo(ZERO) == 0 && aas.getSuspend().compareTo(ZERO) == 0) {
continue;
}
if (fjOff.getID() != null) {
fjOff = (FJOffense) accDao.getById(FJOffense.class, fjOff.getID());
}
BigDecimal assAmt = aas.getAssess();
List msgs;
if (fjOff.getID() == null) {
if (ZERO.compareTo(assAmt) >= 0) { // otherwise there is an ugly error coming from an assert way deep.
msgs = new ArrayList();
msgs.add("original assessments need to be positve");
throw new ValidationFailureException(msgs);
}
FineFee finFee = (FineFee) accDao.getById(FineFee.class, fjOff.getFineFee().getID());
fjOff = off.assess(assAmt, finFee, accRcv, accDefPay);
msgs = fjOff.accept(saveValidator);
if (!msgs.isEmpty()) {
throw new ValidationFailureException(msgs);
}
accDao.save(fjOff);
def.add(fjOff);
ThreadSession.flush();
} else {
fjOff = (FJOffense) accDao.getById(FJOffense.class, fjOff.getID());
}
if (aas.getAdjust().equals(ZERO) == false) {
FinancialJudgmentAdjustmentTransaction fjAdjTrn = fjOff.adjust(aas.getAdjust(),
reasonType, ovrApprovalBean.getApprover(), accRcv, accDefPay);
msgs = fjAdjTrn.accept(saveValidator);
if (msgs.isEmpty() == false) {
throw new ValidationFailureException(msgs);
}
accDao.save(fjAdjTrn);
}
if (aas.getSuspend().equals(ZERO) == false) {
FinancialJudgmentSuspensionTransaction fjSusTrn = fjOff.suspend(aas.getSuspend(),
reasonType, ovrApprovalBean.getApprover(), accRcv, accDefPay);
msgs = fjSusTrn.accept(saveValidator);
if (msgs.isEmpty() == false) {
throw new ValidationFailureException(msgs);
}
accDao.save(fjSusTrn);
}
}
if (isBeforeToday(nextDueDate)) {
ArrayList msgs = new ArrayList();
msgs.add("next due date cannot be a passed date");
throw new ValidationFailureException(msgs);
}
def.setDueDate(nextDueDate);
}