doc/coding_style.dox
author deba
Mon, 04 Sep 2006 12:15:20 +0000
changeset 2192 d6e4efb477d8
parent 1788 614ce2dd3cba
child 2391 14a343be7a5a
permissions -rw-r--r--
Bug fix
rethrow of exception missing
alpar@507
     1
/*!
alpar@507
     2
alpar@921
     3
\page coding_style LEMON Coding Style 
alpar@507
     4
alpar@811
     5
\section naming_conv Naming Conventions
alpar@507
     6
alpar@667
     7
In order to make development easier we have made some conventions
alpar@667
     8
according to coding style. These include names of types, classes,
alpar@667
     9
functions, variables, constants and exceptions. If these conventions
alpar@667
    10
are met in one's code then it is easier to read and maintain
alpar@667
    11
it. Please comply with these conventions if you want to contribute
alpar@921
    12
developing LEMON library.
athos@603
    13
alpar@2157
    14
\note When the coding style requires the capitalization of an abbreviation,
alpar@2157
    15
only the first letter should be upper case.
alpar@2157
    16
alpar@2157
    17
\code
alpar@2157
    18
XmlReader
alpar@2157
    19
\endcode
alpar@2157
    20
alpar@2157
    21
alpar@955
    22
\warning In some cases we diverge from these rules.
alpar@955
    23
This primary done because STL uses different naming convention and
alpar@955
    24
in certain cases
alpar@955
    25
it is beneficial to provide STL compatible interface.
alpar@955
    26
alpar@955
    27
\subsection cs-files File Names
alpar@955
    28
alpar@955
    29
The header file names should look like the following.
alpar@955
    30
alpar@955
    31
\code
alpar@955
    32
header_file.h
alpar@955
    33
\endcode
alpar@955
    34
alpar@1083
    35
Note that all standard LEMON headers are located in the \c lemon subdirectory,
alpar@955
    36
so you should include them from C++ source like this:
alpar@955
    37
alpar@955
    38
\code
alpar@955
    39
#include <lemon/header_file.h>
alpar@955
    40
\endcode
alpar@955
    41
alpar@955
    42
The source code files use the same style and they have '.cc' extension.
alpar@955
    43
alpar@955
    44
\code
alpar@955
    45
source_code.cc
alpar@955
    46
\endcode
alpar@955
    47
alpar@614
    48
\subsection cs-class Classes and other types
athos@603
    49
alpar@955
    50
The name of a class or any type should look like the following.
alpar@507
    51
alpar@507
    52
\code
alpar@507
    53
AllWordsCapitalizedWithoutUnderscores 
alpar@507
    54
\endcode
alpar@507
    55
alpar@614
    56
\subsection cs-func Methods and other functions
athos@603
    57
alpar@955
    58
The name of a function should look like the following.
alpar@507
    59
alpar@507
    60
\code
alpar@507
    61
firstWordLowerCaseRestCapitalizedWithoutUnderscores 
alpar@507
    62
\endcode
alpar@507
    63
alpar@614
    64
\subsection cs-funcs Constants, Macros
athos@603
    65
alpar@955
    66
The names of constants and macros should look like the following.
alpar@507
    67
alpar@507
    68
\code
alpar@507
    69
ALL_UPPER_CASE_WITH_UNDERSCORES 
alpar@507
    70
\endcode
alpar@507
    71
alpar@614
    72
\subsection cs-loc-var Class and instance member variables, auto variables 
alpar@507
    73
alpar@955
    74
The names of class and instance member variables and auto variables (=variables used locally in methods) should look like the following.
alpar@507
    75
alpar@507
    76
\code
alpar@507
    77
all_lower_case_with_underscores 
alpar@507
    78
\endcode
alpar@507
    79
alpar@614
    80
\subsection cs-excep Exceptions
alpar@507
    81
alpar@955
    82
When writing exceptions please comply the following naming conventions.
athos@603
    83
alpar@507
    84
\code
alpar@507
    85
ClassNameEndsWithException
alpar@507
    86
\endcode
alpar@507
    87
deba@1788
    88
or
deba@1788
    89
deba@1788
    90
\code
deba@1788
    91
ClassNameEndsWithError
deba@1788
    92
\endcode
deba@1788
    93
alpar@991
    94
\section header-template Template Header File
alpar@991
    95
alpar@1083
    96
Each LEMON header file should look like this:
alpar@991
    97
alpar@991
    98
\include template.h
alpar@991
    99
alpar@507
   100
*/