|
|
|
CHAPTER 6 : Layout
6.13 'do..while'Consider the confusion that may arise from using the do..while construct in the following form:
do
<<< page break or top of screen here >>>
while ( --GameSteps > 0 );
The while statement looks like it has an empty main block, and is a good candidate for confusion. Even without a page break, the confusion can still happen, particularly if the preceding block is more than a few lines long, or if code after the while looks like it is a part of a while loop. This can be rectified by including it on the same line as the closing brace, possibly with a blank line before it, to make the while stand out more:
do ------------------------------------------ Note that this is also an argument for using braces in all do loops.
|
|
|
|
|
||||