1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
%%
%% This file is part of the ViTE project.
%%
%% This software is governed by the CeCILL-A license under French law
%% and abiding by the rules of distribution of free software. You can
%% use, modify and/or redistribute the software under the terms of the
%% CeCILL-A license as circulated by CEA, CNRS and INRIA at the following
%% URL: "http://www.cecill.info".
%%
%% As a counterpart to the access to the source code and rights to copy,
%% modify and redistribute granted by the license, users are provided
%% only with a limited warranty and the software's author, the holder of
%% the economic rights, and the successive licensors have only limited
%% liability.
%%
%% In this respect, the user's attention is drawn to the risks associated
%% with loading, using, modifying and/or developing or reproducing the
%% software by the user in light of its specific status of free software,
%% that may mean that it is complicated to manipulate, and that also
%% therefore means that it is reserved for developers and experienced
%% professionals having in-depth computer knowledge. Users are therefore
%% encouraged to load and test the software's suitability as regards
%% their requirements in conditions enabling the security of their
%% systems and/or data to be ensured and, more generally, to use and
%% operate it in the same conditions as regards security.
%%
%% The fact that you are presently reading this means that you have had
%% knowledge of the CeCILL-A license and that you accept its terms.
%%
%%
%% ViTE developers are:
%%
%% - COULOMB Kevin
%% - FAVERGE Mathieu
%% - JAZEIX Johnny
%% - LAGRASSE Olivier
%% - MARCOUEILLE Jule
%% - NOISETTE Pascal
%% - REDONDY Arthur
%% - VUCHENER Clément
%%
\section{Convention to code}
\textbf{Gereralities}
\begin{itemize}
\item The software is totally written using C++ language.
\item Source files must be named \textit{*.cpp} and headers \textit{*.hpp}
\item Code must have commentaries in order to create automatically documentation using the \textit{Doxygen} tool.
\item The indentation is 4 spaces.
\item Directories are organized using modules.
\end{itemize}
\textbf{Variables}
\begin{itemize}
\item Variables' names only contain letters and numbers. Letters belong to [a-z] and [0-9], excluding [A-Z].\textit{eg : temp, size2}
\item If a variable is composed of more than one word, then words must be separated with the \textbf{underscore symbol}, and all the letters are in [a-z][0-9] as said above. \textit{eg : number\_of\_item, size\_of\_window, ...}
\item Boolean variables must have a name that remain their functionality, so their names must start with the prefix \textit{is\_} or \textit{has\_}. \textit{eg : is\_enabled}
\item Attributes of classes or structures must begin with the symbol \textbf{underscore}.\textit{eg : \_name, \_is\_enabled, \_width}
\end{itemize}
\textbf{Constants}
\begin{itemize}
\item Constants are written using only [A-Z] and [0-9].
\item If a constant is composed by more than one word, then they must be, as for variables, separated using the \textbf{underscore} symbol.
\end{itemize}
\textbf{Functions and methods}
\begin{itemize}
\item Functions' names only contain letters and numbers. Letters belong to [a-z] and [0-9], excluding [A-Z].\textit{eg : set\_width(), get\_size()}
\item The names of the functions must always contain an action verb.
\item Accessors must start with the \textit{get\_} verb followed by the nature of the object returned. \textit{eg : get\_length(), get\_value()}
\item Mutators must start with the \textit{set\_} verb followed by the field modificated.\textit{eg : set\_size(), set\_value()}
\item Functions which return a boolean must start with \textit{is\_}.
\item Each opening of bloc must be on the same line as the prototype of the function, the condition, whereas the end must be on a new line.
Eg~:
\begin{verbatim}if(bool) {
}
else {
}
\end{verbatim}
\end{itemize}
\textbf{Classes}
\begin{itemize}
\item The names of the classes must begin with an upper-case letter followed with only lower-case.
\end{itemize}
\textbf{.cpp files}
\begin{itemize}
\item Namespaces are declared in the \textit{.cpp} and not in the \textit{.hpp} file.
\item For classes, each \textit{.cpp} file corresponds to a \textit{.hpp} file, with exactly the same name. Headers are included in the \textit{.cpp} files.
\item The file contains the implementation of all the functions declared in the \textit{.hpp} file (unless virtual functions).
\end{itemize}
\textbf{.hpp files}
\begin{itemize}
\item Classes are defined within a \textit{.hpp} file of same name, no function is implemented within (unless templates).
\item The file begins with a \textit{\#ifndef} instruction followed by \textit{CLASS\_NAME\_HPP}
\item Then a \textit{\#define} instruction followed by \textit{CLASS\_NAME\_HPP} as above.
\item It is preferable to put includes in the \textit{.cpp} tather than in the \textit{.hpp}
\item Classes begin with the declarations of the variables, followed by the constructors and the destructor, and finally the declarations of the methods.
\item The \textit{private} keyword must clearly be written such as \textit{public}.
\item The file must end by the \textit{\#endif} instruction.
\end{itemize}
|