syque.com

The Psychology of Quality and More

| Menu | Books | Share | Search | Settings |

C Style: Standards and Guidelines (contents)

CHAPTER 9 : Data Usage

PART 4 : USAGE

CHAPTER 9 : Data Usage
9.1 Declarations
9.2 Using floating point numbers
9.3 Using 'typedef'
9.4 Using global data
9.5 Using Structures
9.6 Using Unions
9.7 Using Arrays
9.8 Using Pointers
9.9 Using bit structures
9.10 Using Constants
9.11 Using 'static' declarations
9.12 Initializing variables
9.13 Summary

<--Prev page | Next page -->

 

9.13  Summary

  • Be consistent with declaration style.
  • Decide whether to define data within inner blocks.
  • Use floating point numbers only where necessary.
  • Do not compare floating point numbers for equality.
  • typedef major variable types, but not all variables.
  • typedef common sizes of number variable, including BOOL.
  • Use typedef rather than #define or struct Tag.
  • Minimize use of global data. Hide it, and pass pointers or call operator functions which insulate it.
  • For global data files, use header files to describe the data.
  • Keep structures functionally cohesive.
  • Avoid large structures - nest them instead.
  • Minimize use of unions.
  • Arrays give more information than pointers.
  • Use arrays of pointers rather than sparse multi-dimensional arrays.
  • Use NULL with the null pointer.
  • Only reallocate pointers to the same type or to void *.
  • Minimize the use of bit structures.
  • Always #define magic numbers, except basic use of 0 and 1.
  • #define bit constants as hexadecimal, using lowercase x and showing all bits.
  • Beware of operations with constants going out of range.
  • Use capital L for long.
  • Use quoted characters for character constants, but never quote more than one character (or hex for non-printing).
  • Compare boolean expressions with FALSE.
  • Use sizeof, rather than a constant.
  • Use enum, rather than #define, unless wide portability is essential.
  • Define rules for initializing variables.
  • Explicitly initialize static data.

<--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