Next: Optimization Up: Some Notes on Previous: Avoid Extensions

Structured Programming

In general, if your language supports programming constructs such as do or for loops, if ... then ... else, while loops, case statements, use them.

Most of the time, go to statements are a poor subsitute: they make the code hard to read, hard to modify, and error-prone. But it is not correct to say that they should always be avoided. For example, it is good procedure to exit subroutines by jumping to a single return statement, rather than to scatter return statements all over the place. In that case, if you later want to do something at the end of the subroutine (such as print a debugging message), you need only worry about a single location.


Next: Optimization Up: Some Notes on Previous: Avoid Extensions