FIFE forums

FIFE Development => Framework development => Topic started by: prock on May 29, 2012, 01:32:11 pm

Title: Finalizing the C++ Coding Standards
Post by: prock on May 29, 2012, 01:32:11 pm
Hi all,

I'm currently working on finalizing the C++ coding standards I've been talking about in IRC the past few days.   Here is what I have so far:

Some of the standards we currently use in FIFE have not really be followed and we have a mash of different standards.  Using the old standards document I tried to sum the up what I think the standards are the best I could.

There are a couple outstanding questions in my mind as far as standards go:

What are you guys thoughts?

Title: Re: Finalizing the C++ Coding Standards
Post by: vdaras on May 29, 2012, 06:05:55 pm
1. For variable names I would say camelcase is preferable, its easier to recognize distinct words in the name.

2. I like the m_ prefix in members, better than the plain m, because it's also consistent with camelcase for variables. I wouldn't like e.g g_ for global variables or s_(scoped?) because it makes code obscure.

3. The solution you found seems ok.

4. Bad thing with typedefs is that they depend on the level of abstraction, so I think it's hard to come up with a single rule on this. I like integer types having the _t suffix because it makes code more intuitive, I wouldn't like an eg. std::list typedef to have it though.
Title: Re: Finalizing the C++ Coding Standards
Post by: vtchill on June 01, 2012, 10:08:57 am
I agree with everything vdaras said and would add for member variables we specify lowerCamelCase.

I like UpperCamelCase for class names.

I'm not sure a stickler on typedefs so much simply because these can be a very limited scope such as a typedef inside the private section of a class. However I do agree with typedefs that are essentially global like uint32_t having the _t on the end.
Title: Re: Finalizing the C++ Coding Standards
Post by: prock on June 01, 2012, 12:09:48 pm
I've been looking at our class names and I'm not sure about #3 here and the idea I included.   I don't think it really works with our classes.  GLImage is an example.  If we used the idea in #3 it would remain the same.  If we didn't use that rule the other option would be to use GlImage.  Another example is OpenGLGuiGraphics... That one would remain the same but the alternative would be OpenGlGuiGraphics.  It provides a bit better work separation in that case.  What do you guys think?

  • variable names -  currently is a mash between lowercase, camelcase.. etc etc.  We need to finalize our standard here.
  • qualifying variable scope - we use m_ for members.  Did we want to change that?  What about adding some more?
  • abbreviations and acronyms - we currently use a mixture of class/type names that capitalize abbreviations and acronyms.  I did some searching online and some suggest that when you use an abbreviation or acronym that is 2 characters long, put them all in caps and when the acronym is longer then 2 char's, use a capital for the first character.
  • typedefs - We use a mixture of a lot of different standards here like:  SomeType_t, SomeType, sometime_t, uint32_t....   What should we do here?
Title: Re: Finalizing the C++ Coding Standards
Post by: prock on June 12, 2012, 10:21:39 am
Okay I think I have finalized the coding standards.  I have replaced the old standards on the Wiki with the new standards.  Check it out here: (