IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 514


Ignore:
Timestamp:
Apr 23, 2004, 11:57:43 AM (22 years ago)
Author:
eugene
Message:

changes to coding requirements from MHPCC comments

Location:
trunk/doc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/design/specs.tex

    r424 r514  
    1 %%% $Id: specs.tex,v 1.5 2004-04-15 01:38:47 eugene Exp $
     1%%% $Id: specs.tex,v 1.6 2004-04-23 21:57:43 eugene Exp $
    22\documentclass[panstarrs]{panstarrs}
    33
     
    172172\subsubsection{Software Coding Requirements}
    173173
    174 \paragraph{CSCI Deliverable}
    175 
    176 All final source code generated for the IPP is to be delivered via
    177 CVS, including the test code.  CVS revision history shall be included
    178 and made available via CVS.
    179 
    180174\paragraph{Languages}
    181175
     
    205199defined in the document TBD}.
    206200
     201\paragraph{Naming Conventions}
     202
     203Header files must have names starting \code{ps} or \code{p_ps} for
     204private interface definitions. The latter must appear in a
     205subdirectory \code{private} of whichever directory is being searched
     206for the public header files.
     207
     208Functions visible at global scope which are part of the public API
     209must have names begining with \code{ps}, and follow the naming
     210conventions in the coding standard.  Functions that are visible at
     211global scope but which are not part of the public interface must have
     212names begining with \code{p_ps}.  Functions that are local to a file
     213must \textit{not} start \code{ps} (or \code{p_ps}).
     214 
     215Variables visible at global scope which are part of the public API
     216must have names begining with \code{ps}, and follow the naming
     217conventions in the coding standard.  Variables that are visible at
     218global scope but which are not part of the public interface must have
     219names begining with \code{p_ps}.  Variables that are local to a file
     220must \textit{not} start \code{ps} (or \code{p_ps}).
     221
     222The names of all enumerated types and C-preprocessor symbols (but not
     223variables declared \code{const}) must start with \code{PS_}, in the
     224case of public symbols, or \code{P_PS_}, for private symbols.  The
     225rest of the name must be uppercase with words separated by underscores
     226(\code{_}). An exception is the case of system utilities implemented
     227as macros, in which case the names must conform to the convention for
     228function names.
     229
     230When defining a function to convert from one type to another, the name
     231should be of the form \code{psOldToAlloc}, e.g.\hfil\break
     232\code{psEquatorialToEcliptic} (\emph{not}
     233\code{psEquatorial2Ecliptic}).
     234
     235\paragraph{C Programming Guidelines}
     236
     237Functions that assign to a variable should list that argument
     238\textit{first}, following the pattern of \code{strcpy}; e.g.
     239\begin{verbatim}
     240void psAddToVector(restrict psVec *outVec, const restrict psVec *inVec,
     241                   int val);
     242\end{verbatim}
     243
     244Type definitions should always be accompanied by prototypes for their
     245constructors and destructors, following these guidelines:
     246
     247\begin{itemize}
     248\item The constructor name should consist of the type name followed by
     249\code{Alloc}; e.g. a type \code{psImage} would be created by a
     250function
     251\begin{verbatim}
     252psImage *psImageAlloc(int nrow, int ncol);
     253\end{verbatim}
     254
     255\item The type should be freed with a destructor named \code{typeFree}, e.g.
     256\begin{verbatim}
     257void psImageFree(psImage *img);
     258\end{verbatim}
     259
     260\item The constructor must never return \code{NULL}, and no code calling the
     261constructor should ever check the return value.
     262
     263\item The destructor must not return a value.
     264
     265\item The destructor must handle being passed \code{NULL} by simply
     266returning immediately. This should not be treated as an error
     267condition.
     268
     269\item Constructors and Destructors should use the memory reference
     270  counter facilities of the PSLib memory management system.
     271
     272\end{itemize}
     273
    207274\paragraph{Commenting and Documentation}
    208275
     
    223290Source code version control shall be implemented with CVS. 
    224291
     292\paragraph{CSCI Deliverable}
     293
     294All final source code generated for the IPP is to be delivered via
     295CVS, including the test code.  CVS revision history shall be included
     296and made available via CVS.
     297
    225298\paragraph{Platform architectures and operating systems}
    226299
     
    238311such as those caused by lex-generated code. 
    239312
    240 Although the code must compile successfully under all three listed
     313Although the code must compile successfully under both listed
    241314operating systems, unit testing should only be performed for the
    242315x86/Linux combination.
     
    244317\paragraph{Software Configuration}
    245318
    246 \tbd{Makefiles, directory structures, UPS, etc}
     319\tbd{deferred}
    247320
    248321\subsubsection{Architectural Components}
  • trunk/doc/misc/codeConventions.tex

    r505 r514  
    1 %%% $Id: codeConventions.tex,v 1.14 2004-04-22 22:33:38 price Exp $
     1%%% $Id: codeConventions.tex,v 1.15 2004-04-23 21:57:43 eugene Exp $
    22\documentclass[panstarrs]{panstarrs}
    33
     
    171171e.g. for file \file{psThing.h}:
    172172\begin{verbatim}
    173 /*
     173/** \file psThing.h
    174174 * Support for psThings
    175175 */
     
    186186} psThing;
    187187
     188/// make a new psThing
    188189psThing *psThingAlloc(int nthing);
     190
     191/// free an existing psThing
    189192void psThingFree(psThing *thing);
    190193
     
    486489
    487490All globally-visible symbols must be declared in a suitable header
    488 (.h) file.  Global private symbols (i.e.  those named \code{p_ps})
    489 should not appear in public header files, but rather in files whose
    490 names begin \code{p_ps}.
     491(.h) file.  Global private symbols should not appear in public header
     492files, but rather in separate, private header files.
    491493
    492494\subsection{Number Per Line}
     
    576578\item
    577579Function declarations should be preceeded by a short comment
    578 describing what the function does.
    579 
    580 \tbd{Discuss Doxygen}
     580describing what the function does.  These comment blocks should
     581include doxygen-style comments to provide a brief desription as well
     582as other warnings, bugs, etc as needed.
    581583
    582584\item The function's type should appear on the same line as the
     
    871873rigid adherence to the guideline.
    872874 
     875{ \small
    873876\begin{tabular}{lp{3in}p{3in}}
    874877\textbf{Identifier Type} &
     
    898901
    899902The names of all externally visible functions (i.e. all those that are
    900 not declared \code{static}) should be verbal phrases, in mixed
    901 case. The first two characters should be \code{ps}, with the first
    902 letter of each internal word capitalized.
    903 
    904 Functions that are visible at global scope but are not considered part
    905 of the public interface should be prefixed \code{p_ps}.
    906 
    907 Functions that are local to a file should \textit{not} start
    908 \code{ps} (or \code{p_ps}).
    909  
     903not declared \code{static}) should be verbal phrases, in mixed case.
     904
     905Namespaces should be protected by using special naming prefixes to
     906restrict the name space in particular libraries.  For example, the
     907PSLib functions are all prefixed with \code{ps}.
     908
    910909&
    911910
     
    927926standard. Non-globally visible words should start with a lowercase
    928927first letter; Internal words start with capital letters.
    929 
    930 Variables visible at global scope should begin with \code{ps},
    931 or \code{p_ps} if not considered part of the public interface.
    932 Variables that are local to a file should \textit{not} start
    933 with \code{ps} (or \code{p_ps}). These variables should be Capitalised
    934 at the beginning of each word.
    935928
    936929Variable names should be short yet meaningful. The choice of a
     
    943936
    944937&
    945 \code{int i; char c; float myWidth;}\hfil\break
     938\code{int i;}\hfil\break
     939\code{char c;}\hfil\break
     940\code{float myWidth;}\hfil\break
    946941\hfil\break
    947942\code{int psNumOTA;}\hfil\break
     
    959954enumerated types.
    960955
    961 The names of all enumerated types and C-preprocessor symbols (but not
    962 variables declared \code{const}) declared should start with
    963 \code{PS_} or \code{P_PS_} and the rest of the name should
    964 be uppercase with words separated by underscores (\code{_}). In the case of
    965 system utilities implemented as macros, the names may conform to the
    966 usual \PS{} conventions (e.g. \code{psAlloc}).
    967 
    968956&
    969957\code{#define PS_MAXLEN 40}\hfil\break
     
    971959
    972960\end{tabular}
     961}
    973962
    974963%------------------------------------------------------------------------------
     
    978967\subsection{When to Make Symbols Global}
    979968
    980 Declare all functions and variables \code{static} within a
    981 file if at all possible (n.b. do not confuse this use of \code{static}
    982 with its usage to make auto-variables within a function persistent).
     969Declare all functions and top-level variables \code{static} within a
     970file if they are not needed outside of the file.  {\bf Note:} do not
     971confuse this use of \code{static} with its usage to make
     972auto-variables within a function persistent.
    983973
    984974\subsection{Constants}
     
    987977small integers such as -1, 0, and 1 which are permitted to e.g. appear
    988978in a \code{for} loop as counter values. 
     979
     980\subsection{Type Qualifiers (const and restrict)}
     981
     982All interfaces and type definitions should use \code{const} and
     983\code{restrict} wherever appropriate. For example,
     984\begin{verbatim}
     985typedef struct {
     986    int n;
     987    float *restrict vec;
     988} psVec;
     989
     990psVec *psVecAdd(const restrict* psVec s1, const restrict* psVec s2);
     991\end{verbatim}
     992
     993\textit{{\bf Note:} compilers are free to ignore the \code{restrict}
     994keyword, so all code should be written to explicitly handle aliasing}.
     995
     996\subsection{structs and typedefs}
     997
     998All structs should be defined as \code{typedef}s.
     999
     1000A struct should not include a struct
     1001tag unless it's self-referential; E.g.
     1002\begin{verbatim}
     1003typedef struct myStruct {               // Omit "myStruct"
     1004    int x;
     1005} myStruct;
     1006
     1007typedef struct yourStruct {             // OK
     1008    struct yourStruct *next;
     1009    int x;
     1010} yourStruct;
     1011\end{verbatim}
    9891012
    9901013\subsection{Variable Assignments}
     
    11011124
    11021125\subsubsection{Special Comments}
     1126
     1127Doxygen has special comments which are used to provide specific notes
     1128in the code.  These are added in as special entries and sections in
     1129the Doxygen-generated documentation.  These special comments should be
     1130used in addition to the Doxygen usage to make these types of
     1131conditions easily searchable.
     1132
    11031133\begin{itemize}
    11041134\item
    1105 Use \code{XXX} in a comment to flag something that is bogus but works.
     1135Use \code{\warning} in a comment to flag something that is bogus but works.
    11061136
    11071137\item
    1108 Use \code{FIXME} to flag something that is bogus and broken.
    1109 
    1110 \tbd{Check Doxygen versions of these special comments. I could not
    1111 find any occurrence of \code{@notused@} in the Doxygen documentation}
    1112 \item
    1113 Use \code{NOTREACHED} to indicate a line of code that cannot be reached,
     1138Use \code{\bug} to flag something that is bogus and broken.
     1139
     1140\item
     1141Use \code{\todo} to note additional work to be done
     1142
     1143\item
     1144Use \code{\note} to make other general notes
     1145
     1146\item
     1147Use \code{\test} to list test cases
     1148
     1149\item
     1150Use \code{\notreached} to indicate a line of code that cannot be reached,
    11141151e.g.
    11151152\begin{verbatim}
     
    11211158
    11221159\item
    1123 Use \code{NOTUSED} to indicate unused arguments to a function:
     1160Use \code{\notused} to indicate unused arguments to a function:
    11241161e.g.
    11251162\begin{verbatim}
     
    11331170\end{verbatim}
    11341171\end{itemize}
    1135 
    1136 \subsubsection{\label{LAllocFree}10.4.6     Constructors/Destructors}
    1137 
    1138 Type definitions should always be accompanied by prototypes for
    1139 their constructors and destructors:
    1140 
    1141 \begin{itemize}
    1142 \item  The constructor should consist of the type name followed by
    1143 \code{Alloc}; e.g. a type \code{psImage} would
    1144 be created by a function
    1145 \begin{verbatim}
    1146 psImage *psImageAlloc(int nrow, int ncol);
    1147 \end{verbatim}
    1148 
    1149 \item  Similarly, the type should be freed with a destructor named
    1150 \code{typeFree}, e.g.
    1151 \begin{verbatim}
    1152 void psImageFree(psImage *img);
    1153 \end{verbatim}
    1154 
    1155 \item  The constructor should never return \code{NULL}, and
    1156 no code calling the constructor should ever check the return value.
    1157 
    1158 \item  The destructor must not return a value.
    1159 
    1160 \item  The destructor should handle being passed \code{NULL}
    1161 by simply returning immediately. This should not be treated as
    1162 an error condition.
    1163 
    1164 \item  The destructor should call \code{psMemGetRefCounter}; if the value is greater
    1165   than one, the destructor should simply call \code{psMemDecrRefCounter} and return.
    1166 
    1167 \end{itemize}
    1168 
    1169 \subsection{\label{LConvOps}Naming Conversion Operators}
    1170 
    1171 When defining a function to convert from one type to another, the
    1172 name should be of the form \code{psOldToAlloc}, e.g.\hfil\break
    1173 \code{psEquatorialToEcliptic} (\emph{not} \code{psEquatorial2Ecliptic}).
    1174 
    1175 \subsection{Order of I/O Arguments}
    1176 
    1177 Functions that assign to a variable should list that argument
    1178 \textit{first} (i.e. following the pattern of \code{strcpy}); e.g.
    1179 \begin{verbatim}
    1180 void psAddToVector(restrict psVec *outVec, const restrict psVec *inVec,
    1181                    int val);
    1182 \end{verbatim}
    1183 
    1184 \subsection{Type Qualifiers (const and restrict)}
    1185 
    1186 All interfaces and type definitions should use \code{const} and
    1187 \code{restrict} wherever appropriate. For example,
    1188 \begin{verbatim}
    1189 typedef struct {
    1190     int n;
    1191     float *restrict vec;
    1192 } psVec;
    1193 
    1194 psVec *psVecAdd(const restrict* psVec s1, const restrict* psVec s2);
    1195 \end{verbatim}
    1196 
    1197 \textit{{\bf Note:} compilers are free to ignore the \code{restrict}
    1198 keyword, so all code should be written to explicitly handle aliasing}.
    1199 
    1200 \subsection{structs and typedefs}
    1201 
    1202 All structs should be defined as \code{typedef}s.
    1203 
    1204 A struct should not include a struct
    1205 tag unless it's self-referential; E.g.
    1206 \begin{verbatim}
    1207 typedef struct myStruct {               // Omit "myStruct"
    1208     int x;
    1209 } myStruct;
    1210 
    1211 typedef struct yourStruct {             // OK
    1212     struct yourStruct *next;
    1213     int x;
    1214 } yourStruct;
    1215 \end{verbatim}
    12161172
    12171173%------------------------------------------------------------------------------
  • trunk/doc/pslib/psLibSRS.tex

    r391 r514  
    1 %%% $Id: psLibSRS.tex,v 1.3 2004-04-07 03:26:07 eugene Exp $
     1%%% $Id: psLibSRS.tex,v 1.4 2004-04-23 21:57:43 eugene Exp $
    22\documentclass[panstarrs]{panstarrs}
    33
     
    7777\subsubsection{Software Coding Requirements}
    7878
    79 \subsubsubsection{CSCI Deliverable}
    80 
    81 All final source code generated for the IPP is to be delivered via
    82 CVS, including the test code.  CVS revision history shall be included
    83 and made available via CVS.
    84 
    85 \subsubsubsection{Languages}
     79\paragraph{Languages}
    8680
    8781Source code shall be in C.  All source code shall be compiled with
     
    9084Scripting language shall be in \tbd{Python, version TBD}.
    9185
    92 \subsubsubsection{Interfaces}
     86\paragraph{Interfaces}
    9387
    9488Access to low-level Library functions shall be provided via C APIs
     
    9892processing jobs shall be available via the UNIX shell.
    9993
    100 \subsubsubsection{Coding Standards}
     94\paragraph{Coding Standards}
    10195
    10296The C code shall comply with ANSI Standard C99.  Because the delivered
     
    110104defined in the document TBD}.
    111105
    112 \subsubsubsection{Commenting and Documentation}
     106\paragraph{Naming Conventions}
     107
     108Header files must have names starting \code{ps} or \code{p_ps} for
     109private interface definitions. The latter must appear in a
     110subdirectory \code{private} of whichever directory is being searched
     111for the public header files.
     112
     113Functions visible at global scope which are part of the public API
     114must have names begining with \code{ps}, and follow the naming
     115conventions in the coding standard.  Functions that are visible at
     116global scope but which are not part of the public interface must have
     117names begining with \code{p_ps}.  Functions that are local to a file
     118must \textit{not} start \code{ps} (or \code{p_ps}).
     119 
     120Variables visible at global scope which are part of the public API
     121must have names begining with \code{ps}, and follow the naming
     122conventions in the coding standard.  Variables that are visible at
     123global scope but which are not part of the public interface must have
     124names begining with \code{p_ps}.  Variables that are local to a file
     125must \textit{not} start \code{ps} (or \code{p_ps}).
     126
     127The names of all enumerated types and C-preprocessor symbols (but not
     128variables declared \code{const}) must start with \code{PS_}, in the
     129case of public symbols, or \code{P_PS_}, for private symbols.  The
     130rest of the name must be uppercase with words separated by underscores
     131(\code{_}). An exception is the case of system utilities implemented
     132as macros, in which case the names must conform to the convention for
     133function names.
     134
     135When defining a function to convert from one type to another, the name
     136should be of the form \code{psOldToAlloc}, e.g.\hfil\break
     137\code{psEquatorialToEcliptic} (\emph{not}
     138\code{psEquatorial2Ecliptic}).
     139
     140\paragraph{C Programming Guidelines}
     141
     142Functions that assign to a variable should list that argument
     143\textit{first}, following the pattern of \code{strcpy}; e.g.
     144\begin{verbatim}
     145void psAddToVector(restrict psVec *outVec, const restrict psVec *inVec,
     146                   int val);
     147\end{verbatim}
     148
     149Type definitions should always be accompanied by prototypes for their
     150constructors and destructors, following these guidelines:
     151
     152\begin{itemize}
     153\item The constructor name should consist of the type name followed by
     154\code{Alloc}; e.g. a type \code{psImage} would be created by a
     155function
     156\begin{verbatim}
     157psImage *psImageAlloc(int nrow, int ncol);
     158\end{verbatim}
     159
     160\item The type should be freed with a destructor named \code{typeFree}, e.g.
     161\begin{verbatim}
     162void psImageFree(psImage *img);
     163\end{verbatim}
     164
     165\item The constructor must never return \code{NULL}, and no code calling the
     166constructor should ever check the return value.
     167
     168\item The destructor must not return a value.
     169
     170\item The destructor must handle being passed \code{NULL} by simply
     171returning immediately. This should not be treated as an error
     172condition.
     173
     174\item Constructors and Destructors should use the memory reference
     175  counter facilities of the PSLib memory management system.
     176
     177\end{itemize}
     178
     179\paragraph{Commenting and Documentation}
    113180
    114181Commenting of delivered C and Python code shall follow the C and
     
    124191documentation shall be delivered as PDF documents.
    125192
    126 \subsubsubsection{Version Control}
     193\paragraph{Version Control}
    127194
    128195Source code version control shall be implemented with CVS. 
    129196
    130 \subsubsubsection{Platform architectures and operating systems}
     197\paragraph{CSCI Deliverable}
     198
     199All final source code generated for the IPP is to be delivered via
     200CVS, including the test code.  CVS revision history shall be included
     201and made available via CVS.
     202
     203\paragraph{Platform architectures and operating systems}
    131204
    132205Makefiles shall be provided with appropriate flags set so that all
     
    143216such as those caused by lex-generated code. 
    144217
    145 Although the code must compile successfully under all three listed
     218Although the code must compile successfully under both listed
    146219operating systems, unit testing should only be performed for the
    147220x86/Linux combination.
    148221
    149 \subsubsubsection{Software Configuration}
     222\paragraph{Software Configuration}
    150223
    151224\tbd{deferred}
Note: See TracChangeset for help on using the changeset viewer.