|
When making changes to the code please follow these steps.
Unfortunately RobotBattle code has very little style since it has been
written over many years. I had no particular coding style when I started
RB and have changed several times since then. These days I like the
following basic style guideline. While not much of the code in RB matches
this today, I am changing it slowly. The best example in RB is DDrawHelper.
If people do not like part or all of this, bring it up on RBDEV.
- Avoid lines longer than about 80 columns.
- Indentations are four spaces. No tabs should be in the
code. This sounds strange but experience has proven this a good
policy. Tabs are handled poorly by many tools.
- Avoid Hungarian notation, except for some standard Windows things.
- Non K&R style aligned brackets. Like this:
if( test == true )
{
// do something
}
- Class, struct, and enum type names have every word capitalized:
class SymbolTable
- Public member functions have each word capitalized. The first word
is often a verb.
bool GetValue( const char *varName );
- Private and protected member functions are prefixed with
"_" .
void _RecalcLayout( );
- Member variables should almost always be private. They are prefixed
with "_" and the first word is not capitalized. Following
words are capitalized. Public members also start with "_".
bool _radarOn;
- Function arguments and stack variables follow the same convention as
member variables, but do not start with "_".
- Global constants and #defines are in all CAPS. Words usually
separated by "_"
const int MAX_WIDTH = 30;
- Global variables follow the same convention as other variables but
are prefixed with "g_"
extern class CWinrob32App *g_winrobApp;
- Large comment blocks outside of function scope (such as function
headers) are formatted as below. Comments inside functions use C++
style // comments, never /* */ comments. This allows for commenting
out entire functions with /* */. All functions should have a header
block even if the block is left empty.
/*****************************************************************************
comments go here
*****************************************************************************/
- All files should start with the standard header text. You can
cut-and-paste from headers.txt.
Don't worry about fixing up the file names, CVS will update these when
you commit the file.
|