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

 

 

  © Syque 1995-2013

Massive Content -- Maximum Speed