So I decided to create a coding guidelines since my code is getting bigger (approximately 10k+ lines). I loosely use Insomniac Coding Guidelines with a few tweaks. It might not be the best, but at least it fits my mind. So if you're interested, here is my coding guidelines:
Notes:
libraries (e.g. math and until classes) does not required to follow a coding guidelines to support portability.
REQUIRED PREFIX
m_(variable name) for class member
f_(variable name) for function parameter member
l_(variable name) for local member
g_(variable name) for global member
s_(variable name) for static member
(CAPS variable name) for preprocessing-defined member
OPTIONAL PREFIX
(m/f/s)_p_(variable name) for pointer
(m/f/s)_a_(variable name) for array
(m/f/s)_k_(variable name) for constant value
OTHER REGULATION
put space before and after arithmetic operator
e.g.: a + b // right
a+b // wrong
put space before and after pointer * and address & definition
e.g.: int * thisPointer; // right
int *thisPointer; // wrong
use is(Condition) for method returning boolean method
e.g.: isEnable(), isDrawable(), isColliding(Obj * f_obj)
For commenting, I try to follow Doxygen supported comment. I'm currently developing it. There are others that I would like to put on my list but most of it are just a trivia problem such as always start curly braces on a new line. And I'm curious why Insomniac prefer C type casting compared to C++. Currently I'm converting my codes to support this guidelines, so expect less feature on the next Triangle Wars update.
No comments:
Post a Comment