2 ms·
I used goto's fairly often to separate the happy path from the unhappy one. That's way better than confusing jumbles of if statements. if(something_bad) {
by Gibbon1 4y ago
I used goto's fairly often to separate the happy path from the unhappy one. That's way better than confusing jumbles of if statements.
if(something_bad)
{
err = BADTHING1;
goto oops;
}
// more stuff
return 0;
oops:
return err;
I'll add
1. keep code that performs calculations separate from code that performs side effects. In fact isolate the latter as much as possible.
2. Avoid spooky action at a distance. Code should relentlessly work towards a clear goal.