|
|
|
#Programming Style
|
|
|
|
> Here's what I could understand from Kristaba's habits ~Eiyeron
|
|
|
|
|
|
|
|
FiXos seems based on snake_case, which means that only lower case is used and underscores (`_`) are used to separate words in variable/function/files names.
|
|
|
|
|
|
|
|
## Namespaces
|
|
|
|
Prefixes are given to public variables or all functions and is based on the filename. Theses prefixes can be shortened if it's too long.
|
|
|
|
|
|
|
|
## Naming variables
|
|
|
|
- normal variable : `type this_is_variable`
|
|
|
|
- static variable : `static type _private_variable`
|
|
|
|
- pointer : `type *pointer_to_something`
|
|
|
|
## Naming functions
|
|
|
|
- normal and static : `(static) type function(type argument, type *pointer) {`
|
|
|
|
- function pointer : inconsistent and should be fixed.
|
|
|
|
## Code format
|
|
|
|
|
|
|
|
Here's a sample on how FiXos code should look. (Precisions shouldbe given on spacing, space v.s. tabs, using blank lines, etc...)
|
|
|
|
```c
|
|
|
|
void sample_function_1(int c) {
|
|
|
|
int a;
|
|
|
|
float *b;
|
|
|
|
|
|
|
|
b = (float*)malloc(sizeof(float));
|
|
|
|
if(b == NULL)
|
|
|
|
return;
|
|
|
|
for(i=0; i<10; i++)
|
|
|
|
_*b += 2*c + i;
|
|
|
|
if(i < b) {
|
|
|
|
*b = i - *b;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch(c) {
|
|
|
|
case 1: return 5; break;
|
|
|
|
case 2:
|
|
|
|
case 3: return 8 break;
|
|
|
|
}
|
|
|
|
free(b);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
``` |
|
|
|
\ No newline at end of file |