doc/coding_style.dox
author ladanyi
Wed, 02 Jul 2008 12:37:47 +0000
changeset 2615 2bf1f6e3d5ae
parent 2391 14a343be7a5a
permissions -rw-r--r--
Fix bug caused by m4 consuming pairs of square brackets (#108).
alpar@2391
     1
/* -*- C++ -*-
alpar@2391
     2
 *
alpar@2391
     3
 * This file is a part of LEMON, a generic C++ optimization library
alpar@2391
     4
 *
alpar@2553
     5
 * Copyright (C) 2003-2008
alpar@2391
     6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
alpar@2391
     7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
alpar@2391
     8
 *
alpar@2391
     9
 * Permission to use, modify and distribute this software is granted
alpar@2391
    10
 * provided that this copyright notice appears in all copies. For
alpar@2391
    11
 * precise terms see the accompanying LICENSE file.
alpar@2391
    12
 *
alpar@2391
    13
 * This software is provided "AS IS" with no warranty of any kind,
alpar@2391
    14
 * express or implied, and with no claim as to its suitability for any
alpar@2391
    15
 * purpose.
alpar@2391
    16
 *
alpar@2391
    17
 */
alpar@2391
    18
alpar@507
    19
/*!
alpar@507
    20
alpar@921
    21
\page coding_style LEMON Coding Style 
alpar@507
    22
alpar@811
    23
\section naming_conv Naming Conventions
alpar@507
    24
alpar@667
    25
In order to make development easier we have made some conventions
alpar@667
    26
according to coding style. These include names of types, classes,
alpar@667
    27
functions, variables, constants and exceptions. If these conventions
alpar@667
    28
are met in one's code then it is easier to read and maintain
alpar@667
    29
it. Please comply with these conventions if you want to contribute
alpar@921
    30
developing LEMON library.
athos@603
    31
alpar@2157
    32
\note When the coding style requires the capitalization of an abbreviation,
alpar@2157
    33
only the first letter should be upper case.
alpar@2157
    34
alpar@2157
    35
\code
alpar@2157
    36
XmlReader
alpar@2157
    37
\endcode
alpar@2157
    38
alpar@2157
    39
alpar@955
    40
\warning In some cases we diverge from these rules.
alpar@955
    41
This primary done because STL uses different naming convention and
alpar@955
    42
in certain cases
alpar@955
    43
it is beneficial to provide STL compatible interface.
alpar@955
    44
alpar@955
    45
\subsection cs-files File Names
alpar@955
    46
alpar@955
    47
The header file names should look like the following.
alpar@955
    48
alpar@955
    49
\code
alpar@955
    50
header_file.h
alpar@955
    51
\endcode
alpar@955
    52
alpar@1083
    53
Note that all standard LEMON headers are located in the \c lemon subdirectory,
alpar@955
    54
so you should include them from C++ source like this:
alpar@955
    55
alpar@955
    56
\code
alpar@955
    57
#include <lemon/header_file.h>
alpar@955
    58
\endcode
alpar@955
    59
alpar@955
    60
The source code files use the same style and they have '.cc' extension.
alpar@955
    61
alpar@955
    62
\code
alpar@955
    63
source_code.cc
alpar@955
    64
\endcode
alpar@955
    65
alpar@614
    66
\subsection cs-class Classes and other types
athos@603
    67
alpar@955
    68
The name of a class or any type should look like the following.
alpar@507
    69
alpar@507
    70
\code
alpar@507
    71
AllWordsCapitalizedWithoutUnderscores 
alpar@507
    72
\endcode
alpar@507
    73
alpar@614
    74
\subsection cs-func Methods and other functions
athos@603
    75
alpar@955
    76
The name of a function should look like the following.
alpar@507
    77
alpar@507
    78
\code
alpar@507
    79
firstWordLowerCaseRestCapitalizedWithoutUnderscores 
alpar@507
    80
\endcode
alpar@507
    81
alpar@614
    82
\subsection cs-funcs Constants, Macros
athos@603
    83
alpar@955
    84
The names of constants and macros should look like the following.
alpar@507
    85
alpar@507
    86
\code
alpar@507
    87
ALL_UPPER_CASE_WITH_UNDERSCORES 
alpar@507
    88
\endcode
alpar@507
    89
alpar@614
    90
\subsection cs-loc-var Class and instance member variables, auto variables 
alpar@507
    91
alpar@955
    92
The names of class and instance member variables and auto variables (=variables used locally in methods) should look like the following.
alpar@507
    93
alpar@507
    94
\code
alpar@507
    95
all_lower_case_with_underscores 
alpar@507
    96
\endcode
alpar@507
    97
alpar@614
    98
\subsection cs-excep Exceptions
alpar@507
    99
alpar@955
   100
When writing exceptions please comply the following naming conventions.
athos@603
   101
alpar@507
   102
\code
alpar@507
   103
ClassNameEndsWithException
alpar@507
   104
\endcode
alpar@507
   105
deba@1788
   106
or
deba@1788
   107
deba@1788
   108
\code
deba@1788
   109
ClassNameEndsWithError
deba@1788
   110
\endcode
deba@1788
   111
alpar@991
   112
\section header-template Template Header File
alpar@991
   113
alpar@1083
   114
Each LEMON header file should look like this:
alpar@991
   115
alpar@991
   116
\include template.h
alpar@991
   117
alpar@507
   118
*/