From 2481eb4e1ad95f2d24d6a1c566f238458f7d78b5 Mon Sep 17 00:00:00 2001 From: Carlos Daniel Ruvalcaba Valenzuela Date: Sat, 15 Sep 2007 01:30:49 -0700 Subject: [PATCH] Added Latex Document, Code Style Guideliness --- docs/codingstyle.tex | 166 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 docs/codingstyle.tex diff --git a/docs/codingstyle.tex b/docs/codingstyle.tex new file mode 100644 index 0000000..9189687 --- /dev/null +++ b/docs/codingstyle.tex @@ -0,0 +1,166 @@ +\documentclass{article} +\usepackage{palatino} + +\newcommand{\bold}[1]{{\raggedleft\bfseries\upshape #1}} + +\begin{document} + +\section{Classes} + +\subsection{Class names} + +Class names should be UpperCase. + +\bold{Reason:} Code uniformity. + +\subsubsection{Examples} + +\bold{Good:} + +\begin{verbatim} +class SocketIPC{ +\end{verbatim} + +\bold{Bad:} + +\begin{verbatim} +class socketipc{ +\end{verbatim} + +\subsection{Function Names} + +Class function names should be UpperCase, except +when using any of the following prefixes, in which +case they whould be in cammelCase: + +\begin{itemize} +\item{is} - isAlive +\item{get} - getValue +\item{set} - setValue +\item{has} - hasKey +\end{itemize} + +\bold{Reason:} Code readability. + +\subsubsection{Examples} + +\bold{Good:} + +\begin{verbatim} +int getValue(); +int Height(); +\end{verbatim} + +\bold{Bad:} + +\begin{verbatim} +int GetValue(); +int height(); +\end{verbatim} + + +\section{Spaces} + +\subsection{Identation} + +Code should be idented with tabs. + +\bold{Reason:} Code readability. + +\subsubsection{Examples} + +\bold{Good:} + +\begin{verbatim} +int func(){ + int i; + + for (i = 0; i < 100; i++){ + /* Do something */ + } +} +\end{verbatim} + +\bold{Bad:} + +\begin{verbatim} +int func(){ +int i; +for (i = 0; i < 100; i++){ +/* Do something */ +} +} +\end{verbatim} + +\subsection{For Loops} + +For construct should have an space after "for", there should not +be spaces between the parenthesis. + +\bold{Reason:} Code readability and uniformity. + +\subsubsection{Examples} + +\bold{Good:} + +\begin{verbatim} +for (i = 0; i < 100; i++){ +} +\end{verbatim} + +\bold{Bad:} + +\begin{verbatim} +for( i = 0 ; i < 100 ; i++ ){ +} +\end{verbatim} + + +\section{Brackets} + + +\subsection{Loop Brackets} + +They should be on the same line of the loop construct. + +\bold{Reason:} Wastes a line. + +\subsubsection{Examples} + +\bold{Good:} + +\begin{verbatim} +for (i = 0; i < 100; i++){ +\end{verbatim} + +\bold{Bad:} + +\begin{verbatim} +for (i = 0; i < 100; i++) +{ +\end{verbatim} + + +\subsection{Function Brackets} + +They should be in the same line of the function. + +\bold{Reason:} Having the brancket in the next line wastes it, +probably doesn't add much to readability. + +\subsubsection{Examples} + +\bold{Good:} + +\begin{verbatim} +int main(int argc, char **argv){ +\end{verbatim} + +\bold{Bad:} + +\begin{verbatim} +int main(int argc, char **argv) +{ +\end{verbatim} + +\end{document} -- 2.11.4.GIT