Defining Programming Standards   
for Professional Programmers 
  

         

Home

Contents

1: Standards

2: Psychological Factors

3: General Principles

4: Commenting

5: Naming

6: Code Layout

7: File Layout

8: Language Usage

9: Data Usage

10: Programming Usage

11: Implementing Standards

A: Example Standard

B: References

C: Glossary

Syque

About

Share this page:

Google
C Style
syque.com
Web

 

 

Books and
more at:

USA:

In association with amazon.com

UK:

In Association with Amazon.co.uk

Canada:

In Association with amazon.ca

 

 

CHAPTER 6 : Code 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 -->

<-- Prev chapter | Next chapter -->

 

The most visible aspect of coding style is the way in which the code is laid out. It is a common subject of significant controversy amongst programmers, where individual layout styles are strongly defended. The difference of opinion is often due to the pattern-recognition characteristics of the mind, where a style even slightly different from your own somehow looks 'wrong' (see 2.1).

This level of individualism is often tolerated, as it does not appear to affect the actual code which is written. However, it can affect the readability of the code for a future reader, especially if he is trying to maintain a program written by several people, each using a different style.

This chapter considers the basic layout of code statements, focusing on the positioning of the fundamental elements of the language. It also strays into the realms of usage where changes in text do not change the basic meaning of the code (for example, use of parentheses in expressions).

 

<--Prev page | Next page -->

 

 

  © Syque 1995-2013

Massive Content -- Maximum Speed