development Conventions

From OpenKore Wiki
Revision as of 17:31, 30 October 2012 by EternalHarvest (talk | contribs)
Jump to navigation Jump to search

Disclaimer: this page is made of existing openkore source and common sense. These are only guidelines which may not always apply.

General

Look at existing code. If nothing says otherwise, do the same as most of the code does (methodology, names, formatting etc).

Formatting

K&R style, with opening brace on the same line with all declarations.

Indent with TABs. Don't use TABs for other means. There is no defined column size for TAB.

sub test {
<TAB> if ($a == $b) {
<TAB> <TAB> something();
<TAB> <TAB> something_else($a, $b);
<TAB> }
<TAB> $twenty = 20;
<TAB> $ten    = 10; # use spaces if you want that for some reason
}

Naming

Language: only english

Constants: UPPER_CASE

Variables: $camelCase or $underscore_separated

Packet "names": underscore_separated_words

Config option names: camelCase, regular words like "auto" at the end, however underscore may separate a common prefix (teleportAuto). Underscore is also internally used to represent config blocks

Comments

Language: only english, with no translations to other languages; quotations from sources on another languages may be included if it's necessary

Keywords: FIXME, TODO