AGS Engine Coding Conventions: Difference between revisions
Updated to the naming convention used in practice for years
(Removed 64-bit section, as being outdated) |
(Updated to the naming convention used in practice for years) |
||
Line 24: | Line 24: | ||
// this code is inside the braces | // this code is inside the braces | ||
} // closing brace | } // closing brace | ||
Curly braces may be omitted after conditional or loop statements if there is only one line of code in the following block. In case of combined if/else statement only omit curvy braces if each of the blocks consist of one line. | |||
===Whitespace=== | ===Whitespace=== | ||
Line 78: | Line 80: | ||
===Naming Conventions=== | ===Naming Conventions=== | ||
The user types: classes, structs, enums and typedefs, - as well as global entities such as namespaces, global constants and global variables should be named using upper "upper" {{Wikipedia|CamelCase}} notation.. Publicly exposed data (class members, methods, globals, etc.) should also follow CamelCase notation. | |||
Class methods and public data fields should also follow CamelCase notation. Private class fields should be named using lower camelCase and prefixed with an underscore ('_') to distinguish single-worded members from local variables. | |||
Local variables | Local variables and function arguments should be named in all lowercase with underscores separating parts of name when necessary (but not as a prefix). | ||
Names should be as descriptive as possible, without being overly verbose. Functions particularly should indicate what they actually do, so a name such as "GetID()" would be preferred over simply naming the function "ID()". Bear in mind that some compilers may have issue if using names that are overly long, so use discretion to determine the best names. | Names should be as descriptive as possible, without being overly verbose. Functions particularly should indicate what they actually do, so a name such as "GetID()" would be preferred over simply naming the function "ID()". Bear in mind that some compilers may have issue if using names that are overly long, so use discretion to determine the best names. |