Naming Conventions
Following a standard of identifier naming conventions in your source code helps during maintenance, integration, and group collaborative projects.
When source code has been gaining dust for a few months and you need to go back to make a change, or someone new takes over your source code, its beneficial to have followed a recognized standard in your naming conventions. This way you know that "sName" is a string that's probably someone or something's name, and not have to dig through code to find out if it was "__NAME", "name", "Name", or any one of the other derivatives.
When integrating another developer's module into your own, like a town for example, its even easier if both you and the other developer have followed the standard naming conventions. For integration purposes you may need to modify some of the original module developer's scripts for the NPCs so they react to certain variables set within your primary module.
In a group project it is especially important that all members agree upon and follow a set of naming conventions and coding standards, otherwise the source code falls into a hodgepodge mess and anarchy ensues.
Variables should note their appropriate data type at the beginning of their name, followed by intercapitalization (Hungarian notation). A table of naming prefixes appears below.
Type | Prefix | Example |
---|---|---|
action | a | aKill |
effect | e | eConPenalty |
event | ev | evAttacked |
float | f | fResult |
int | n | nAge |
int (boolean) | b | bIsSpell |
itemproperty | ip | ipProperty |
location | l | lJumpTo |
object | o | oPC |
string | s | sName |
struct | str | strPerson |
talent | t | tSkillHide |
vector | v | vVelocity |
sqlquery | sql | sqlPreparedQuery |
author: Charles Feduke