|
|
@ -2,7 +2,7 @@ |
|
|
|
*Version 1 -- A first draft at formalizing a common coding practice for SingOS Development* |
|
|
|
|
|
|
|
|
|
|
|
## On naming in general |
|
|
|
## On naming |
|
|
|
|
|
|
|
We encourage long but descriptive identifier names like, |
|
|
|
|
|
|
@ -49,4 +49,53 @@ but with parameter names in all-caps: |
|
|
|
|
|
|
|
## On indentation |
|
|
|
|
|
|
|
We use 4 spaces per indent, at least in C-style languages. (^: |
|
|
|
We use 4 spaces per indent, at least in C-style languages. (^: |
|
|
|
|
|
|
|
## On brace-placement |
|
|
|
|
|
|
|
What do we prefer? |
|
|
|
This: |
|
|
|
|
|
|
|
if (something) |
|
|
|
{ |
|
|
|
do_stuff(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
this_other_thing(); |
|
|
|
} |
|
|
|
|
|
|
|
Or this: |
|
|
|
|
|
|
|
if (something) { |
|
|
|
do_stuff(); |
|
|
|
} |
|
|
|
else { |
|
|
|
this_other_thing(); |
|
|
|
} |
|
|
|
|
|
|
|
## On return statements |
|
|
|
|
|
|
|
We prefer an explicit else case even though a return was found in an above branch: |
|
|
|
|
|
|
|
if (some_condition) |
|
|
|
{ |
|
|
|
return "Olga"; |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
return "Finn"; |
|
|
|
} |
|
|
|
|
|
|
|
As opposed to: |
|
|
|
|
|
|
|
(BAD) |
|
|
|
|
|
|
|
if (some_condition) |
|
|
|
{ |
|
|
|
return "Olga"; |
|
|
|
} |
|
|
|
|
|
|
|
return "Finn"; |
|
|
|
|
|
|
|
(BAD) |