The prime purpose of a good layout is to make the logical structure of
the code more obvious to people. Good layout must be: |
Fundamental Theorem of Formating A visual layout is considered good if and only if it shows the logical structure of the program. |
Layout Techniques -White Space - Parentheses |
Layout Styles - Pure Blocks Exmaple: - Endline Layout Example: - Emulating Pure Blocks Example: - begin and end as Block Boundaries Example: |
Layout of Individual Statements - Limits the length of the statement line
length to 80 characters and use only one statement per line Example: - Indent assignment to a point after the "=" Example: - Align Data Declarations, and use one data declaration per line. Example: - Align Pointer and reference declarations Example: - Indent a comment with its corresponding code Example: |
Example: |
Authors: Alice Mok, Rena Xu, Mandy Wong, Anthony Leung,
Andy Ho, Gary Lo
Reference: Code Complete, A Practical Handbook of Software
Construction. Steve McConnell. Microsoft Press (1993)
Last Modified: June 15, 2000
Copyright 2000 Department of Computer Science, University
of Regina.