What is preferred: goto or if else()
This is a question about programming style, preferences, efficiency, and risk.
We are working on a state machine were multiple conditions are checked for a potential state transition. We are debating what is better, safer, more efficient, or simply more elegant: goto LABEL, or if else() blocks? The goto statement is simple, but if else() blocks are perhaps more robust in a team environment. See options 1 and 2 below. What do you recommend? Thanks!
Option 1:
if (condition_1 true)
{
[do something]
goto END_OF STATE;
}
if (condition_2 true)
[do something]
goto END_OF STATE;
Option 2:
if (condition_1 true)
[do something]
else if (condition_2 true)
{
[do something]
}
