Changes between Version 8 and Version 9 of Coding_Conventions


Ignore:
Timestamp:
Nov 24, 2011, 4:23:34 PM (12 years ago)
Author:
Philip Taylor
Comment:

more conventions

Legend:

Unmodified
Added
Removed
Modified
  • Coding_Conventions

    v8 v9  
    8989        m_Value = value;
    9090    }
     91
     92    for (int i = 0; i < value; ++i)
     93        DoSomethingElse(i, value);
     94
    9195    return value;
    9296}
     
    131135LOGERROR(L"Failed to load item %d from file %ls", i, path.c_str());
    132136}}}
    133  This gets display on screen in red, and saved in the log files.
     137 This gets display on screen in red, and saved in the log files. `LOGERROR` takes `wprintf`-style format strings.
    134138 ''Exception:'' Code in `source/lib/` can't use `LOGERROR` (it can only use things defined in `source/lib/`).
    135139
     
    168172  * ''Exception:'' `source/lib/` and `source/simulation2/` and `source/scriptinterface/` tend to prefer `std::[w]string` instead.
    169173
     174 * Compare strings using `==` (not e.g. "`a.compare(b) == 0`"). Compare to literals directly (e.g. "`someCStrVariable == "foo"`", not "`someCStrVariable == CStr("foo")`").
     175
    170176 * For portability, use the following formats for printf-style functions:
    171177{{{
     
    180186 * In header files, avoid `#include` and use forward declarations wherever possible.
    181187
    182  * Sometimes it's nice to put `#include`s in alphabetical order.
     188 * Sometimes it's nice to put `#include`s in alphabetical order. (It's a bit prettier, and makes it easier to find if some header is already in the list or not.) (But when `Foo.cpp` includes `Foo.h`, that should usually go before every other include (except for `precompiled.h` which must always be first).)
    183189
    184190 * Class names are !CamelCase and prefixed with `C`, e.g. `CGameObject`. Member functions are !CamelCase, e.g. `CGameObject::SetModifiedFlag(...)`. Member variables are !CamelCase prefixed with `m_`, e.g. `CGameObject::m_ModifiedFlag`. Files are named `GameObject.cpp`, `GameObject.h`, usually with one major class per file (possibly with some other support classes in the same files).