Hey,
I have a situation where (pseudo-code):
Action a;
Object o;
if(objectIsPartOfGroup(o, "Group1"))
a = treatCaseGroup1();
if(a != indecisive)
return a;
if(objectIsPartOfGroup(o, "Group2"))
a = treatCaseGroup2();
if(a != indecisive)
return a;
if(objectIsPartOfGroup(o, "Group3"))
a = treatCaseGroup3();
if(a != indecisive)
return a;
.
.
.
I was wondering if there is a pattern applicable to this situation, so that I don't have to repeat the "if(a != indecisive) return a;" check after every step? I find that repeating this code over and over is not very... professional? It adds a whole lot of code lines and doesn't at all help clarity, therefore I find it sucks.
EDIT: an object can be part of group1 and group2 and group3, etc... so say an object is part of group1 and the action is undecisive, since it is also part of group2, it will be treated again and again, untill all groups have been treated. At the end, the result CAN be undecisive too!
Thanks for your help!
Dave