home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!darwin.sura.net!udel!princeton!siemens!kong!wood
- From: wood@siemens.com. (Jim Wood)
- Newsgroups: comp.software-eng
- Subject: Re: C Code Layout
- Message-ID: <wood.724079768@kong>
- Date: 11 Dec 92 13:16:08 GMT
- References: <AJ3U.92Dec6151332@larch.cs.virginia.edu> <1992Dec7.113438.13054@spider.co.uk> <1g3to7INNd11@uwm.edu> <1992Dec11.080937@eklektix.com>
- Sender: news@siemens.siemens.com
- Lines: 59
-
- My format for C code modules:
-
- /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Module: X.C
- Purpose: ....
- Author: Jim Wood, Siemens Corporate Research, Inc. (609) 734-3643
- Group: Software Testing
- Project: SSP (Sample Stupid Project)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- Functions defined in this module:
- Add: Integer X Integer --> Integer
- Is_Positive: Integer --> Boolean
- Macros defined in this module:
- MINIMUM: Integer X Integer --> Integer
- MAXIMUM: Integer X Integer --> Integer
- Data types defined in this module:
- complex_number: {Integer, Integer}
- Global variables declared in this module:
- Generate_Identifier: unique identifier increment
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
-
- #include "type.h" /* data type definitions */
- #include "universe.h" /* macros and constants for all modules */
- #include "a.h" /* modules related to this one */
- #include "b.h"
- #include "c.h"
-
-
- INTEGER Add(a, b)
- INTEGER a, /* first integer to add */
- b; /* second integer to add */
- /*
- PRE A precondition goes here.
- POST The sum of two integers is returned.
- GENL General comments go here.
- NOTE Special notes, especially for maintenance, go here.
- */
- {
- INTEGER index = 0; /* local integer variable */
-
- return(a + b);
- } /* end ADD */
-
- ....
-
- The point is to define standard header comments for the module, write
- comments for each routine in the module, write short descriptive comments
- for each formal parameter and local variable of each routine, and also to
- identify the end of a routine.
-
- Clarity and brevity are the main keywords. If people are to understand
- the code, the need to quickly know what each routine does and what each
- variable means.
-
- --
- Jim Wood [jwood@siemens.siemens.com] (609) 734-3643
- "Rise up on the wings of eagles, and two step among the stars.
- You are not forgotten. Your smile will echo forever."
- -- Ryerson Schwark, to our friend Rob Bernardo.
-