development Conventions

From OpenKore Wiki
Revision as of 16:10, 18 April 2012 by EternalHarvest (talk | contribs) (Created page with '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 nothin…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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

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

Keywords: FIXME, TODO