The following options have appeared:
Using the goto statement:
Start:
goto Data
Data:
goto Finish
Finish:
;
using the switch statement:
switch(m_state) {
case State.Start:
m_state = State.Data;
break;
case State.Data:
m_state = State.Finish;
break;
case State.Finish:
break;
}
using goto and switching between each other:
switch(m_state) {
case State.Start:
goto case State.Data2;
case State.Data1:
goto case State.Finish;
case State.Data2:
m_state = State.Data1;
break;
case State.Finish:
break;
}
I prefer the first option using the goto statement because it is faster and less verbose. But I'm not sure if this is the best option. Performance may be reasonable, but when it comes to readability, I don't know. That is why I am asking this question. Which option do you prefer and why?
source
share