Software Engineering discussion

5 views
Code Complete > Unusual Control Structures

Comments Showing 1-3 of 3 (3 new)    post a comment »
dateUp arrow    newest »

message 1: by [deleted user] (new)

I grew up in the "Never, ever use a goto" era, so it was interesting for me to read some cases where it might make sense to use this construct, if the language supports it.

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.


message 2: by Aleksander (new)

Aleksander Shtuk | 84 comments I don’t think that calculating Fibonacci numbers or factorials with recursion can be considered as silly examples or a problem with computer – science books. These are the classic sequences that help understanding recursion naturally. I think author’s example of using recursion is good only for people already familiar with recursion construction learned from constructing and testing sequences.

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.


message 3: by Erik (new)

Erik | 165 comments I use GOTO statements a few times per year. It work with some C code that calls OCI APIs alot, and that code use alot of macros that have a "goto ExitWithError" component. I think that works nicely.

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.


back to top