Which of the following would you prefer:
SomeEnum enum = SomeEnum.SOMETHING;
if (aString.equals(anotherString)) {
enum = SomeEnum.SOMETHING_ELSE;
}
return foo.bar(enum);
or
if (aString.equals(anotherString)) {
return foo.bar(SomeEnum.SOMETHING_ELSE);
}
return foo.bar(SomeEnum.SOMETHING);
I think I would prefer the first one, because it only has 1 point of return. On the other side I think that the second one is easier to read. What do you think? Maybe you got an even more sophisticated solution.
Aucun commentaire:
Enregistrer un commentaire