home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / software / 4974 < prev    next >
Encoding:
Text File  |  1992-12-15  |  4.9 KB  |  176 lines

  1. Newsgroups: comp.software-eng
  2. Path: sparky!uunet!infonode!ingr!b30news!mueller
  3. From: mueller@b30news.b30.ingr.com ( Phil Mueller )
  4. Subject: Re: C Code Layout [long]
  5. Message-ID: <1992Dec15.130615.22500@b30.ingr.com>
  6. Sender: mueller@b30.ingr.com (Phil Mueller)
  7. Organization: Intergraph
  8. References: <1992Dec7.164154.6312@b30.ingr.com> <1992Dec7.223748.26505@fcom.cc.utah.edu>
  9. Date: Tue, 15 Dec 1992 13:06:15 GMT
  10. Lines: 164
  11.  
  12. In article <1992Dec7.223748.26505@fcom.cc.utah.edu> bryant@ced.utah.edu writes:
  13. >In article 6312@b30.ingr.com, mueller@b30news.b30.ingr.com ( Phil Mueller ) writes:
  14. >>
  15. >> ... I put the function and paramter declaration in the header itself:
  16. >>
  17. >><include files>
  18. >>
  19. >>/* NC NC NC NC NC NC NC NC NC NC NC NC NC NC NC NC NC NC NC NC NC NC NC NC */
  20. >>
  21. >>int function0( arg0, arg1, arg2, arg3, arg4 )
  22. >>int             arg0;   /* i    one-line description of arg0 */
  23. >>int             *arg1;  /* [i]  one-line blah blah blah      */
  24. >>TYPEXYZZY       *arg2;  /* io   arg2 is  */
  25. >>TYPEAGAIN       *arg3;  /* o    arg3 is */
  26. >>double          *arg4;  /* [o]  arg4 is */
  27. >>
  28. >>/* 
  29. >>DESCRIPTION
  30. >>  this function does blah blah blah
  31. >>  blah blah blah
  32. >>  Any further decription of the arguments also go here.
  33. >>
  34. >>HISTORY
  35. >>       Author     Date          Description
  36. >>       -----      ----          -----------
  37. >>        pam     12/07/91        initial spec
  38. >>        moh     12/18/91        made arg1 optional
  39. >>        xac     06/22/92        correct something TR 92w1234
  40. >>
  41. >>NC NC NC NC NC NC NC NC NC NC NC NC NC NC NC NC NC NC NC NC NC NC NC NC NC */
  42. >>
  43. >
  44. >I was resisting, but now I must put in my thoughts on this. I may
  45. >stand alone, but I RESIST the idea of putting a large comment block
  46. >between the declaration of the function and the code of that function.
  47. >There is something to be said for having as much code together as
  48. >possible.
  49. >
  50. >Here is an example of a complete file produced where I work. We
  51. >use RCS and have extraction programs to automatically extract
  52. >documentation (LaTeX) from the source and headers. Comments are
  53. >welcome!
  54. >
  55. >/*File
  56. > *  $RCSfile$
  57. > *  $Revision$
  58. > *  $Author$, $State$, $Locker$
  59. > *  Program : 
  60. > *  Project : 
  61. > *
  62. > *  $Log$
  63. > *  Copyright 1991 by the Center for Engineering Design and
  64. > *    the University of Utah.  All rights reserved.
  65. > *
  66. > *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  67. > *
  68. > *  Description :
  69. > *    
  70. > *
  71. > *  Compile Flags :
  72. > *    flag ; description.
  73. > *
  74. > *  Routines :
  75. > *    name
  76. > *
  77. > *  Assumptions :
  78. > *    description.
  79. > *
  80. > *****************************************************************************/
  81. >
  82. >/* Local Definitions. */
  83. >
  84. >/* System Header Files. */
  85. >
  86. >/* Lab Header Files. */
  87. >
  88. >/* Project Header Files. */
  89. >
  90. >/* Local Header Files. */
  91. >
  92. >/* Local Type Declarations. */
  93. >
  94. >/* Local Function Prototypes. */
  95. >
  96. >/* Global Variable Declarations. */
  97. >
  98. >/* Local Variable Declarations. */
  99. >
  100. >static char
  101. >  *rcs_ident() { return "$Header:$"; }
  102. >
  103. >
  104. >/*
  105. > *  Code for local functions.
  106. > */
  107. >
  108. >
  109. >/*
  110. > *  Code for exported functions.
  111. > */
  112. >
  113. >/*Function*********************************************************************
  114. > *
  115. > *  Name : 
  116. > *  Date : 
  117. > *
  118. > *  Description :
  119. > *    ONE LINE DESCRIPTION.
  120. > *  Side Effects : (optional)
  121. > *    VERY SPECIFIC EXTERNAL SIDE EFFECTS.
  122. > *
  123. > *  Parameters :
  124. > *    type name ; WHAT DOES IT MEAN.
  125. > *  Return Value :
  126. > *    type ; MEANING.
  127. > *
  128. > *  Algorithm : (optional)
  129. > *    DETAILED DESCRIPTION. SHOULD READ LIKE CODE.
  130. > *
  131. > *  Dependencies : (optional)
  132. > *    ASSUMPTIONS MADE IN THE CODE. THINGS THAT COULD CAUSE IT NOT TO WORK.
  133. > *
  134. > *  See Also : (optional)
  135. > *    ROUTINES, MANUALS, MAN PAGES, PAPER DOCUMENTATION.
  136. > *
  137. > *  Known Bugs : (optional)
  138. > *    ANY PROBLEM NOTED WITH THE CODE THAT SHOULD BE FIXED IN TIME.
  139. > *
  140. > *****************************************************************************/
  141. >
  142. >/* End file. */
  143. >
  144. >
  145.  
  146. When I started programming for a living, I put the parameters as comments
  147. separated from the actual declaration.  The *first* time I added a parameter
  148. to a function, I neglected to add it to the comments.  I tried to use the 
  149. function, got the arg list wrong, and crashed.  I decided to put the
  150. actual declaration in the header.
  151.  
  152. >We do not keep track of authorship and all history is kept via the
  153. >RPC checkin logs.
  154. >
  155. >The order of include files, type declarations, etc. is important and
  156. >was done to maximize the number of warnings or errors caused by
  157. >scoping violations.
  158. >
  159. >All templates are inserted automatically upon file creation (we use
  160. >Emacs), we have templates for C and C++, both source and include
  161. >files, functions and types.
  162. >
  163.  
  164. I wish we could do that, but our shop isn't that formal.  In the previous
  165. shop we did do that.
  166.  
  167. >I have been programming using these for almost 2 years and have never
  168. >needed to add much more.
  169.  
  170.  
  171. Oh yeah?  Well I've been using this header for 8 years.  :-)
  172.  
  173. -- 
  174. Phil Mueller    mueller@b30news.b30.ingr.com
  175. The preceeding opinions are not necessarily those of Intergraph Corporation.
  176.