syque.com

The Psychology of Quality and More

| Menu | Books | Share | Search | Settings |

C Style: Standards and Guidelines (contents)

CHAPTER 7 : File Layout

PART 3 : LAYOUT

CHAPTER 7 : File Layout
7.1 Layout of directories
7.2 Division of files
7.3 Considerations for File Layout
7.4 Header files
7.5 Layout of Data files
7.6 Layout of Code files
7.7 Summary

<--Prev page | Next page -->

 

7.7  Summary

  • Aim to keep the number of files in directories that will regularly scanned down to one or two screenfuls (ie. about 50 files).
  • Structure directories by file type/functional area.
  • Organize files to ease navigation and minimize scope.
  • Use functional cohesion to group similar items.
  • Use one public function per file, plus the private functions it calls. Allow more public functions only if they share private functions.
  • Use pagebreaks in files to maximize the amount of related information on one page (ie. at start of major sections and functions).
  • Keep file length within about 20 pages or 1000 lines.
  • Define a template for each file type to help usage of a standard layout.
  • Order files by:
    • Context then definition
    • External items then internal items
    • Public items then private items
    • Name alphabetic order (if no better method)
  • Put a file header comment at the start of every file
  • Use page breaks to put as much of one subject on one page at once.
  • Keep file width to 80 characters or less.
  • Work around default tab setting rather than change it and confuse those who didn't change it.
  • Identify files with a string constant.

Header files:

  • Split header files to reflect the code files they serve.
  • Don't reserve memory in header files.
  • Minimize header file interdependency.
  • Use header files to keep data declarations and their context together
  • Layout header files to reflect the systems they serve.

Data files:

  • Lay out data files to reflect the systems they serve.
  • Be careful to match external declarations with the global data.

Code files:

  • Group '#include's by scope.
  • Separate external items and internal, private items.
  • Put replacement items which are used once near their actual use.
  • Put private function declarations at the start of the file, to form a 'contents list'.
  • Sort functions by a standard scheme, eg. first by public/private, then by alphabetic name order.
  • Keep function length to within one or two pages (or 100 lines).

<--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-
Massive Content -- Maximum Speed