Eliminated searchtree debugging messages; Added UNIX socket (named sockets) support...
[fmail.git] / docs / codingstyle.tex
blob9189687a2bdfaa4906a088f9c003fe3404445d9a
1 \documentclass{article}
2 \usepackage{palatino}
4 \newcommand{\bold}[1]{{\raggedleft\bfseries\upshape #1}}
6 \begin{document}
8 \section{Classes}
10 \subsection{Class names}
12 Class names should be UpperCase.
14 \bold{Reason:} Code uniformity.
16 \subsubsection{Examples}
18 \bold{Good:}
20 \begin{verbatim}
21 class SocketIPC{
22 \end{verbatim}
24 \bold{Bad:}
26 \begin{verbatim}
27 class socketipc{
28 \end{verbatim}
30 \subsection{Function Names}
32 Class function names should be UpperCase, except
33 when using any of the following prefixes, in which
34 case they whould be in cammelCase:
36 \begin{itemize}
37 \item{is} - isAlive
38 \item{get} - getValue
39 \item{set} - setValue
40 \item{has} - hasKey
41 \end{itemize}
43 \bold{Reason:} Code readability.
45 \subsubsection{Examples}
47 \bold{Good:}
49 \begin{verbatim}
50 int getValue();
51 int Height();
52 \end{verbatim}
54 \bold{Bad:}
56 \begin{verbatim}
57 int GetValue();
58 int height();
59 \end{verbatim}
62 \section{Spaces}
64 \subsection{Identation}
66 Code should be idented with tabs.
68 \bold{Reason:} Code readability.
70 \subsubsection{Examples}
72 \bold{Good:}
74 \begin{verbatim}
75 int func(){
76 int i;
78 for (i = 0; i < 100; i++){
79 /* Do something */
82 \end{verbatim}
84 \bold{Bad:}
86 \begin{verbatim}
87 int func(){
88 int i;
89 for (i = 0; i < 100; i++){
90 /* Do something */
93 \end{verbatim}
95 \subsection{For Loops}
97 For construct should have an space after "for", there should not
98 be spaces between the parenthesis.
100 \bold{Reason:} Code readability and uniformity.
102 \subsubsection{Examples}
104 \bold{Good:}
106 \begin{verbatim}
107 for (i = 0; i < 100; i++){
109 \end{verbatim}
111 \bold{Bad:}
113 \begin{verbatim}
114 for( i = 0 ; i < 100 ; i++ ){
116 \end{verbatim}
119 \section{Brackets}
122 \subsection{Loop Brackets}
124 They should be on the same line of the loop construct.
126 \bold{Reason:} Wastes a line.
128 \subsubsection{Examples}
130 \bold{Good:}
132 \begin{verbatim}
133 for (i = 0; i < 100; i++){
134 \end{verbatim}
136 \bold{Bad:}
138 \begin{verbatim}
139 for (i = 0; i < 100; i++)
141 \end{verbatim}
144 \subsection{Function Brackets}
146 They should be in the same line of the function.
148 \bold{Reason:} Having the brancket in the next line wastes it,
149 probably doesn't add much to readability.
151 \subsubsection{Examples}
153 \bold{Good:}
155 \begin{verbatim}
156 int main(int argc, char **argv){
157 \end{verbatim}
159 \bold{Bad:}
161 \begin{verbatim}
162 int main(int argc, char **argv)
164 \end{verbatim}
166 \end{document}