Difference between revisions of "Code Formatting Conventions"

Jump to navigation Jump to search
→‎Naming: Elaborate / clarify a bit
(→‎Doxygen documentation comments: updated doxygen link)
(→‎Naming: Elaborate / clarify a bit)
Line 139: Line 139:
'''Constants'''
'''Constants'''


Basically, you have two choices:
Basically, you have two choices (this has historical reasons, and we probably should try to unify this one day):


<pre>
# Camel case with prefix 'k': <pre> kSomeKludgyConstantName </pre >
kSomeKludgyConstantName // notice k prefix
# All upper case, with words separated by underscores (no leading/trailing underscores): <pre>SOME_KLUDGY_CONSTANT_NAME</pre>
</pre>


or
(As a side remark, we recommend avoiding #define for creating constants, because these can lead to weird and difficult to track down conflicts. Instead use enums or the <code>const</code> keyword.)
 
<pre>
SOME_KLUDGY_CONSTANT_NAME
</pre>


'''Classes'''
'''Classes'''


Mixed case starting with upper case
Camel case starting with upper case.


<pre>
<pre>
Line 159: Line 154:
</pre>
</pre>


'''Class members'''
'''Class member variables'''


Prefixed with '_' and in mixed case (Yo! no underscore separators), starting with lowercase.
Prefixed with '_' and in camel case (Yo! no underscore separators), starting with lowercase.


<pre>
<pre>
Line 169: Line 164:
'''Class methods'''
'''Class methods'''


Mixed case, starting with lowercase.
Camel case, starting with lowercase.


<pre>
<pre>
void thisIsMyFancyMethod();
void thisIsMyFancyMethod();
</pre>
'''Global variables'''
In general you should avoid global variables, but if it can't be avoided, use 'g_' as prefix, camel case, and start with lowercase
<pre>
int g_someGlobaleVariable;
</pre>
</pre>


1,079

edits

Navigation menu