Some programmers follow Edsger Dijkstra’s rules of structured programming.14 Dijkstra
said that every function, and every block within a function, should have one entry and one
exit. Following these rules means that there should only be one return statement in a function,
no break or continue statements in a loop, and never, ever, any goto statements.
While we are sympathetic to the goals and disciplines of structured programming,
those rules serve little benefit when functions are very small. It is only in larger functions
that such rules provide significant benefit.
So if you keep your functions small, then the occasional multiple return, break, or
continue statement does no harm and can sometimes even be more expressive than the single-
entry, single-exit rule. On the other hand, goto only makes sense in large functions, so
it should be avoided.