You are previewing Code Complete, Second Edition.

Code Complete, Second Edition

Cover of Code Complete, Second Edition by Steve McConnell Published by Microsoft Press
O'Reilly logo

Layout Styles

Most layout issues have to do with laying out blocks, the groups of statements below control statements. A block is enclosed between braces or keywords: { and } in C++ and Java, if-then-endif in Visual Basic, and other similar structures in other languages. For simplicity, much of this discussion uses begin and end generically, assuming that you can figure out how the discussion applies to braces in C++ and Java or other blocking mechanisms in other languages. The following sections describe four general styles of layout:

  • Pure blocks

  • Emulating pure blocks

  • Using begin-end pairs (braces) to designate block boundaries

  • Endline layout

Pure Blocks

Much of the layout controversy stems from the inherent awkwardness of the more popular programming ...

The best content for your career. Discover unlimited learning on demand for around $1/day.