Changes between Version 41 and Version 42 of Coding_Conventions
- Timestamp:
- Jun 19, 2019, 12:29:19 AM (5 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Coding_Conventions
v41 v42 12 12 Our code is currently not entirely consistent in places, but the following guidelines attempt to describe the most common style and are what we should converge towards. (Obviously we always want clean, readable, adequately-documented code - lots of articles and books already talk about how to do that - so here we're mostly describing minor details.) 13 13 14 14 15 == Common == 15 16 16 17 - Use the US variant of English when choosing variable names. For example, use 'color' instead of 'colour'. 17 18 19 18 20 == C++ == 21 19 22 === Creating new files === 20 23 * All source files (.cpp, .h) must start with the following GPL license header, before any other content: … … 77 80 * All source files must have the `svn:eol-style` property set to `native` 78 81 82 79 83 === Formatting === 80 84 * Use tabs for indentation, not spaces. … … 138 142 }}} 139 143 144 140 145 === Error reporting === 141 146 See [wiki:Logging] for more info. … … 150 155 151 156 * The engine should try to cope gracefully with `LOGERROR` cases, e.g. abort loading the current file; it should never crash in those cases. 157 152 158 153 159 === Documentation === … … 180 186 * Don't need to bother documenting every line of code or every member function or every member variable; only when it'll add to a competent reader's understanding of the program. 181 187 188 182 189 === Strings === 183 190 * Use `CStr` instead of `std::string`. Use `CStrW` instead of `std::wstring`. (These are subclasses of `std::[w]string` with various extra methods added for convenience.) … … 205 212 std::wstring cppWStr = str.wc_str(); // Don't use c_str() because it breaks OS X build 206 213 }}} 214 207 215 208 216 === Preprocessor instructions === … … 243 251 }}} 244 252 253 245 254 === Misc === 246 255 * In header files, avoid `#include` and use forward declarations wherever possible. … … 333 342 }}} 334 343 344 335 345 == !JavaScript == 336 346 * Use the same basic formatting as described above for C++. … … 396 406 }}} 397 407 408 409 == JSON== 410 * basically follow the JS formatting conventions 411 * when on the same line, insert spaces after {, [, and : and before ] and }; e.g. `{ "foo": "bar" }` and `[ "baz" ]` 412 * use tabs for indentation, not spaces 413 414 398 415 == XML == 399 416 * All XML files should start with … … 406 423 407 424 * Indent using whatever the similar existing XML files use. (Usually two spaces; sometimes four spaces, or tabs, etc.) 425 408 426 409 427 == GLSL ==