I am very much aware that 'goto' is a dirty word in the lexicon of most professional followers of structured programming. So I would ask how the following use of a 'goto' could be replaced.
I'm writing a bridge bidding app. I ask the user "Who dealt". If he did, no problem. If the player on his right dealt (East), then the user must be asked what that player bid. If the player opposite dealt (partner), the user must be asked what the player opposite bid and then what East. If the player on the user's left dealt (West), the user must be asked, in turn, what all those three players bid.
I have an activity "What bid" that displays a screen and is passed either "West", "your partner" or "East" depending on who bid. That activity is called using startActivityForResult and returns the bid that was made. Now here's the thing. I reckon this is the most efficient way to do this:
if (whodealt == "West") {continue}
else if (whodealt == "North") {goto northbid;}
else if (whodealt == "East") {goto eastbid;}
westbid:
startActivityForResult() etc. passing "West";
process result (e.g. store bid)
northbid:
startActivityForResult() etc. passing "your partner";
process result (e.g. store bid)
eastbid:
startActivityForResult() etc. passing "East";
process result (e.g. store bid)
Obviously, I've simplified everything. But isn't the alternative non-goto structure below a bit cumbersome, such as
if (whodealt == "West") {
startActivityForResult() etc. passing "West";
process result (e.g. store bid)
startActivityForResult() etc. passing "your partner";
process result (e.g. store bid)
startActivityForResult() etc. passing "East";
process result (e.g. store bid) }
else if (whodealt == "North") {
startActivityForResult() etc. passing "your partner";
process result (e.g. store bid)
startActivityForResult() etc. passing "East";
process result (e.g. store bid) }
else if (whodealt == "East") {
startActivityForResult() etc. passing "East";
process result (e.g. store bid) }
What do people think about this?