Home Structuring loops

Single-iteration loops

Never write a loop (for loop or while loop) that will either never run or will always runs exactly once. If a loop never runs, just delete it. If a loop always runs once, you didn't really need a loop to begin with.

Special-casing specific iterations

Likewise, avoid structuring the contents of a loop so that a segment of it runs only during a specific iteration. For example, avoid adding in an if statement into a loop that will always run only during the first iteration.

Break and continue

Do not use break and continue statements.