Changes between Version 5 and Version 6 of Coding_Conventions
- Timestamp:
- Jul 22, 2010, 11:45:50 PM (14 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Coding_Conventions
v5 v6 11 11 * All source files (.cpp, .h) must start with the following header, before any other content: 12 12 {{{ 13 /* Copyright (C) 20 09Wildfire Games.13 /* Copyright (C) 2010 Wildfire Games. 14 14 * This file is part of 0 A.D. 15 15 * … … 28 28 */ 29 29 }}} 30 replacing `20 09` with the year that the file was last updated.30 replacing `2010` with the year that the file was last updated. 31 31 32 32 * Wrap header files in include guards, using the name `INCLUDED_`''filename'', e.g. the file `Foo.h` should say: … … 61 61 * 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). 62 62 63 * Use [http://www. cppdoc.com/ CppDoc] comments, e.g.63 * Use [http://www.doxygen.org/ Doxygen] comments, e.g. 64 64 {{{ 65 65 class CExampleObject … … 205 205 * 206 206 * (Notes regarding usage and possible problems etc...) 207 * */208 }}} 209 For single-line comments, `///` can be used as well. The comment text is inserted into the documentation, and can additionally be formatted by certain tags (e.g. `@param description` for function parameters). For more details, see the ! CppDocdocumentation.207 */ 208 }}} 209 For single-line comments, `///` can be used as well. The comment text is inserted into the documentation, and can additionally be formatted by certain tags (e.g. `@param description` for function parameters). For more details, see the !Doxygen documentation. 210 210 211 211 Each method of a class should be documented as well and here is the suggested method of documenting a member function (continuing with `CExample`): … … 221 221 * documenting a member function. 222 222 * @param dummy A dummy parameter. 223 * */223 */ 224 224 void ShowExample(int dummy); 225 225 … … 250 250 * Description : CExample interface file. 251 251 * ========================================================================= 252 * */252 */ 253 253 254 254 /* … … 268 268 * provide an example of documenting a class. 269 269 * Notes regarding usage and possible problems etc... 270 * */270 */ 271 271 class CExample 272 272 { … … 279 279 * documenting a member function. 280 280 * @param dummy A dummy parameter. 281 * */281 */ 282 282 void ShowExample(int dummy); 283 283 … … 304 304 == Singletons == 305 305 306 Much debate regarding the use of global variables has been generated over the years so we will not re-enter that discussion. The Singleton design pattern does provide many benefits over that of a pure global variable. 307 308 We will make use of the Automatic Singleton Utility as described by Scott Bilas in article 1.3 of the "Game Programming Gems", volume I, "An Automatic Singleton Utility". 306 After a long debate, it was decided to not use Singletons and to prefer global variables to them. All global variables have to be prefixed with 'g_' and their initialisation should be as clear and transparent as possible. So, if there's a class like CGame, which needs to exist in a single instance, there will be a pointer declaration called 'g_Game' in Game.h, and all initialisation details will be "hidden" in Game.cpp. There are still some Singletons in the current codebase, but they will be reimplemented and the new code should be written using globals. 309 307 310 308 == Strings ==