I have to assign the result of an operation (a db query or a computation) to a return variable, and eventually perform another operation if the result is not valid (null, empty, ...); however, this pattern happen at least a couple of time, and it seems a code smell to me. Should I refactor it in any way?
String result = planA();
if(!isValid(result))
result = planB();
if(!isValid(result))
result = planC();
if(!isValid(result))
result = planD();
return result;
Aucun commentaire:
Enregistrer un commentaire