Spaceports Coding Standards V 1.0

All the things below are REALLY important!! Only the editor settings and sentences with "should be" are probably not that important. But please do everything mentioned here.


Copyright (C) 2002 by The Spaceports Team
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.1
or any later version published by the Free Software Foundation;
with no Invariant Sections, with no Front-Cover Texts, and with no
Back-Cover Texts. A copy of the license is included in the section
entitled "GNU Free Documentation License".


Version History:

(version - date - editor - comment)
V1.0 - 14/07/02 - Jerome-X - Created


Index
  1. Comments and Headers
  2. Editing Code
  3. CVS Check in files
  4. Editor setting

Each source code file (including .h and .cpp files) must contain the following header:

/*
   Copyright (C) 2002 by The Spaceports Team
   This program is free software; you can redistribute it and/or
   modify it under the terms of the GNU General Public License
   as published by the Free Software Foundation; either version 2
   of the License, or (at your option) any later version.
   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   General Public License for more details.
   You should have received a copy of the GNU General Public
   License along with this program; if not, write to the Free 
   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, 
   MA 02111-1307 USA
*/

Each .h file must contain a comment block for each class definition, placed just above the class definition. This comment block should describe the functionality of the class. Also the initial author of the class should be mentioned. Example:

/**
* TestClass
* This class is just for demonstrating purposes. It's interacting with          
* the class AnotherClass and serves as a blah.
* Author: John Doe
*/
class TestClass : public BasicTestClass
{
...


Each function must contain a comment block in the header file, describing its functionality. Input and Output parameters should be explained there. Only exception: setter and getter functions for properties. These functions only need a comment block if the parameters values are not clear. Note: Only place the comment block in the header file.

Example for commenting functions:
/**
* An example method
* Params:
* [IN] index: an index to something
* [IN/OUT] tester: pointer to ITest that will be modified in this method
* [OUT] inTester: pointer to ITest that will return the original
* Returns:
* The result. TEST_SUCCESSFUL if successful, TEST_FAIL if not.
*/
int performTest(int index, ITest* tester, ITest* inTester);

2. Editing Code

Each line should be not longer than 100 characters. See editor settings

A method should fit on one screen page. If the method is getting larger, try to split it up into different methods.

For readability try to divide logical blocks within a method. Add a small comment above each block describing very briefly what this block does. Do this as soon as you think that the block and the method are fine and wont be changed much. Commenting blocks shouldn't slow down the coding process, but it should also not be forgotten. Try to find the right time when to comment, and keep in mind, that there is nothing worse than a wrong (or old) comment that describes wrong functionality.


3. CVS Check in files

Everytime you commit file changes to the CVS, please add a detailed comment (in the check-in dialog) with all your changes.


4. Editor settings

Tabs should be converted to spaces

standard indent of 2 spaces

Maximum line width of 100 characters