Quote:
Originally Posted by PJo336
Code:
for( int i = 0; i < decisionList.size(); i++) {
makeDecision(decisionList.get(i), theres, 9, params,
in, this, function, which, sucks);
}
..
private void makeDecision(Object obj , theres, 9,
params, in, this, function,
which, sucks) {
if obj == blah {
delete();
} else {
update();
}
}
Quote:
Originally Posted by jjshabado
I'm still not sure if I understand your problem correctly, but as I understand it I think I would do something like:
Code:
private void deleteOrUpdateList(decisionList, ...) {
toDeleteList = new List()
toUpdateList = new List()
for( int i = 0; i < decisionList.size(); i++) {
obj = decisionList.get(i)
if (shouldBeDeleted(obj,...)) {
toDeleteList.append(obj)
} else {
toUpdateList.append(obj)
}
}
//Go through and call your delete/update methods
}
private bool shouldBeDeleted(Object obj, ...) {
return <delete check>;
}
I like jjshabado's suggestion and the advice that follows it, especially regarding naming. The only comment I have is that if you were to use the above solution, also consider refactoring the existing method so that it uses shouldBeDeleted() instead of duplicating the delete check logic.
Code:
private void makeDecision(Object obj , theres, 9,
params, in, this, function,
which, sucks) {
if shouldBeDeleted(obj, ...) {
delete();
} else {
update();
}
}
That way, if the delete check logic ever changes you don't have to worry about it being updated in one place and not the other.