|
|
@ -0,0 +1,52 @@ |
|
|
|
# SingOs Coding Practice |
|
|
|
*Version 1 -- A first draft at formalizing a common coding practice for SingOS Development* |
|
|
|
|
|
|
|
|
|
|
|
## On naming in general |
|
|
|
|
|
|
|
We encourage long but descriptive identifier names like, |
|
|
|
|
|
|
|
token_string_to_id_map |
|
|
|
|
|
|
|
as opposed to, |
|
|
|
|
|
|
|
tok_map |
|
|
|
|
|
|
|
`(Yes, it's a made up example)`. |
|
|
|
|
|
|
|
Short names like 'i' and 'j' may be |
|
|
|
used for super obvious iteration indexes only, |
|
|
|
otherwise, if the body of the loop is big, |
|
|
|
we still prefer something more explicit like: |
|
|
|
|
|
|
|
token_index |
|
|
|
|
|
|
|
## On casing |
|
|
|
|
|
|
|
We use snake-case for all identifiers consisting of multiple words; |
|
|
|
this means that words are underscore seperated. |
|
|
|
|
|
|
|
For variable and procedure names, every letter is lowercase: |
|
|
|
|
|
|
|
our_very_important_variable |
|
|
|
our_very_important_procedure |
|
|
|
|
|
|
|
For all typenames (`structs`, `enums`, `unions`, etc.), |
|
|
|
every word begins with a capitalized letter: |
|
|
|
|
|
|
|
Our_Very_Important_Type |
|
|
|
|
|
|
|
(An exception is made for primitive types like `int`, `float`, `double`, etc). |
|
|
|
|
|
|
|
For value constants (`#defines`), every letter is uppercase (all-caps): |
|
|
|
|
|
|
|
OUR_VERY_IMPORTANT_CONSTANT |
|
|
|
|
|
|
|
Macros acting like procedures should be capitalized like a procedures, |
|
|
|
but with parameter names in all-caps: |
|
|
|
|
|
|
|
our_very_important_macro(PARAMETER, OTHER_PARAMETER) |
|
|
|
|
|
|
|
## On indentation |
|
|
|
|
|
|
|
We use 4 spaces per indent, at least in C-style languages. (^: |