go to previous page   go to home page   go to next page

Answer:

No. It is a black box. If the entry conditions are correct (pizza unwrapped, positioned correctly, correct settings chosen), then the exit conditions are correct (hot pizza. Num, Num.) The internal details are not something you want to think about.


Structure Rule One: Code Block

program block

What if there is a bug? What a cutie!!

If the entry conditions are correct, but the exit conditions are wrong, the bug must be in the block. This is not true if execution is allowed to jump into or out of a block. The bug might be anywhere in the program. Debugging under these conditions is much harder.

Rule 1 of Structured Programming: A code block is structured. In flow charting terms, a box with a single entry point and single exit point is structured.

This may look obvious, but that is the idea. Structured programming is a way of making it obvious that program is correct. (Or, making it obvious where there is a problem.)

Structured programming languages show code blocks with pairs of braces, { ... }, or begin end pairs or other means.

Assembly language and older programming languages, such as early versions of FORTRAN and BASIC, were not designed with structured programming in mind. They do not have syntax for showing program blocks or the other structures of structured programming.

However, it is still possible (and essential) to do structured programming in these languages. You (the programmer) must design the code using structuring principles. Then, when coding you must follow your design.

These old languages included the notorious GOTO statement which sent control from one point in a program to any other point in a program, directly violating Rule One. This was disastrous.


QUESTION 6:

Would it be OK for there to be several exits from a code block, depending on the data it processes?