Changes between Version 8 and Version 9 of Coding_Conventions
- Timestamp:
- Nov 24, 2011, 4:23:34 PM (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Coding_Conventions
v8 v9 89 89 m_Value = value; 90 90 } 91 92 for (int i = 0; i < value; ++i) 93 DoSomethingElse(i, value); 94 91 95 return value; 92 96 } … … 131 135 LOGERROR(L"Failed to load item %d from file %ls", i, path.c_str()); 132 136 }}} 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. 134 138 ''Exception:'' Code in `source/lib/` can't use `LOGERROR` (it can only use things defined in `source/lib/`). 135 139 … … 168 172 * ''Exception:'' `source/lib/` and `source/simulation2/` and `source/scriptinterface/` tend to prefer `std::[w]string` instead. 169 173 174 * Compare strings using `==` (not e.g. "`a.compare(b) == 0`"). Compare to literals directly (e.g. "`someCStrVariable == "foo"`", not "`someCStrVariable == CStr("foo")`"). 175 170 176 * For portability, use the following formats for printf-style functions: 171 177 {{{ … … 180 186 * In header files, avoid `#include` and use forward declarations wherever possible. 181 187 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).) 183 189 184 190 * 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).