So I dont know design patterns (Im working on it I swear), and one of the issues I frequently have in the real world is coming up with nice ways to change functionality for a method that is used 100 times in a large enterprise app. The following is a pretty simplified example, if anyone has any input.
Basically we have a list of objects, well call it decisionList. We iterate over decisionList, and for each object in that list, we decide whether the object will be updated, or deleted.
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();
}
}
So basically, for each object in decisionList, it decides what to do with the items, and then performs the action immediately. Now I have to change it so the actual actions for delete and update happen after EVERY object in decisionList is sorted into their respective lists. So the simple (terrible?) solution is to add in 2 more lists as parameters, and add to that each time we make a decision with the objects. This of course changes the parameters of a method that is possibly used a ton of times, and that breaks the code in many places.
So I hope this wasnt too long or poorly explained. Like I said, its incredibly simplified, but the concept is similar. If anyone has any comments, Id love to hear them!