syque.com

The Psychology of Quality and More

| Menu | Books | Share | Search | Settings |

C Style: Standards and Guidelines (contents)

CHAPTER 6 : Layout

PART 3 : LAYOUT

CHAPTER 6 : Code Layout
6.1 Basic principles of code layout
6.2 Use of Spaces
6.3 Use of blank lines
6.4 Use vertical alignment
6.5 Indentation level
6.6 Line wrapping
6.7 Braces
6.8 Use of parentheses
6.9 Nested single statement
6.10 Empty statements
6.11 'else..if'
6.12 'switch' statements
6.13 'do..while'
6.14 Labels
6.15 Data declarations
6.16 Function declaration
6.17 Preprocessor commands
6.18 Summary

<--Prev page | Next page -->

 

6.3  Use of blank lines

Spaces are used within a line to make individual items more readable, and to indicate the degree of association. Blank lines can be similarly used at the statement level to delimit larger chunks of information.

These 'Breathing points' in the code are often good points at which to put comments, summing up what has, or what is about to, happen. A blank line is itself, in effect, a comment. It says, "Stop, take a breath, look back at what you just read. Did you understand it? Do you need to read it again? Look forwards, can you see the next breathing point? Prepare to take in the next chunk":

 

MovePaperUp( CharHeight );
MoveCarriage( C_LEFT );      /* end of chunk 1 */

GetLine( LineBuf );          /* start of chunk 2 */
PrintLine( LineBuf );

 

Statements naturally tend to come in small chunks. If the chunk is large (ie. more than about 7 lines), then you should be looking for points at which to insert blank lines and/or comments.

The disadvantage of blank lines is that they increase the vertical size of the function, which means that there is less code visible at one time on the screen or page, which in turn means that it may be less easy to scan back (e.g. to find a variable).

 

<--Prev page | Next page -->

 

Site Menu

| Home | Top | Settings |

Quality: | Quality Toolbook | Tools of the Trade | Improvement Encyclopedia | Quality Articles | Being Creative | Being Persuasive |

And: | C Style (Book) | Stories | Articles | Bookstore | My Photos | About | Contact |

Settings: | Computer layout | Mobile layout | Small font | Medium font | Large font | Translate |

 

You can buy books here

More Kindle books:

And the big
paperback book


Look inside

 

Please help and share:

 

| Home | Top | Menu |

© Changing Works 2002-2015
Massive Content -- Maximum Speed