Thursday, December 16, 2010

BitSquid C++ Coding Style

The BitSquid Coding Style Guidelines:


  1. Almost the same as the Google C++ style guide (,which I use and love ;).

  2. I agree with everything but the underscores for variable and function names. I find camel case easier to read than underscores.

    That said, I definitely feel it IS something that I feel should be specified. I'd rather read and code underscores than have a mix anywhere in the code.

    Lastly, the one place I feel a piece of "hungarian-esq" notation works is notating an argument to a function:
    my_func(int a_argument1, int a_argument2)
    // code body

    Though this might harm the type of readability you're looking for, it differentiates arguments from local variables and can help someone scanning the code figure out where the variable came from easily, especially in longer functions (e.g. whether it's a calculated value local to the function or passed in).

  3. I-actually-like-dashes-best,-but-unfortunately-that's-not-valid-C++. Underscores_are_the_next_best_thing_because_what_you_write_is_still_quite_readable. CamelCaseIFindNotVeryReadableAtAll,ButIGuessYouCanGetUsedToIt.

    I haven't felt the need to distinguish arguments, to me they don't seem "special enough" and I like to keep the functions short. Actually I'm not so sure on the hungarian notation on member variables either. It might be clearer to just write this-> everywhere... it's a bit more typing though... and harder to enforce. But all of this is a matter of taste anyway.

  4. When I sit and code in visual studio, i think its nice for example to write m_ and then press ctrl-space to get all member variables. Or for example to write class.get and press ctrl-space to get all the getters from the class. Thats one big reason I think to write m_ before members and get before get functions.

  5. I was refering to this excellent post from time to time, but unfortunately, the link pointing to the coding style stopped working. Is it available anywhere else?

    1. Thanks for noticing, I've found a new home here: