...but all those does not go down to the code level with info on the preferred;
- Coding guidelines
- Commenting guidelines
- Include guidelines
- Filename guidelines
- Review guidelines
So lets discuss that here in this thread:
If there is a firmly established guideline in place, it will help the coding by multiple developers to go much smoother. Also, all developers (coders in particular) should be subscribed to the SVN mailing list and there should be a policy of encouraging review of the code by each other (with reference to the coding guidelines as needed).
The current code in places is a bit messy as far as layout goes, so here's an attempt at getting a format that we can all pseudo agree on to help us keep things readable. i've taken most of this from the scummvm code conventions, and altered it with my personal preferences (well, i did have to format all this )
XBMC Code Formatting Conventions
1. use common sense
these are conventions which we try to follow when writing code for xboxmediacenter. they are this way mainly for reasons of taste, however, sticking to a common set of formatting rules also makes it slightly easier to read through our sources. if you want to submit patches, please try to follow these rules.
as such we don't follow these rules slavishly, in certain cases it is ok (and in fact favorable) to stray from them.
braces in your code should look like the following example:
Quote:if (int i = 0; i < t; i++)
3. indents, at two spaces, using spaces.
in msdev, the settings should be setup as follows:
1. conventional operators surrounded by a space character
Quote:a = (b + c) * d;
2. c++ reserved words separated from opening parentheses by a white space
3. commas followed by a white space
Quote:somefunction(a, b, c);
int d, e;
4. semicolons followed by a space character, if there is more on line
Quote:for (int a = 0; b++; c < d)
dosomething(e); dosomething(f); // this is probably bad style anyway
5. when declaring class inheritance and in a ? construct, colons should be surrounded by white space
Quote:class buswheel : public rubberinflatable
(isnight) ? colormedark() : colormebright();
5. switch / case constructs
dialog::handlecommand(sender, cmd, data);
1. constants - use caps with underscore spacing where necessary.
Quote:const int SOME_KLUDGY_CONSTANT_NAME = 1;
2. variables - only rule is that they are obviously named. hovering in msdevstudio reveals the type, so type prefixing is optional.
3. member variables. prefix with m_
4. global variables. prefix with g_
please post your opinions on this, and i'll update as a consensus is reached.