Software Engineering discussion
Code Complete
>
Unusual Control Structures
date
newest »


I don’t think I’ve ever used GOTO. To me it sounds more like a command from BASIC or FORTRAN languages if I remember it correctly, or examples from Steven’s Advanced Programming in the Unix Environment book. Next time I come across GOTO I will try to remember to come back to read this discussion.

My first paying software job had a coding standard that contained clauses for "never use goto statements" and "only have 1 return statement per function".
Often, I find it's nice to use an early Return when checking a function's preconditions for validity. If input values are not valid, then using an early return makes the code nice and clean.
I agree with the author's comments on recursion, but only when applied to imperative or OO languages. Functional languages are a whole different issue, and they are programmed most efficiently using recursive and list-based techniques. The compiler for functional languages is smart enough to optimize the code in clever ways that bypass the problems discussed in this chapter.