Version 1 (modified by trac, 16 years ago) ( diff )

--

Overview

Where possible, we should endeavour to share Coding Conventions with the engine programmers.

Naming Conventions

Use only alphanumerics (A..Z, a..z, 0-9) and underscores (_) for object names and parameters. Various special characters are reserved for use as delimiters and markers (particularly semicolons), so it's best not to use anything else.

Technically, the hyphen or dash (-) can be used interchangeably with hyphens, but you'll need to reference the string in a different way:

  object.cell_id

is exactly equivalent to

  object["cell-id"]

For consistency, though, it's best to just stick to alphanumerics and underscores.

Variable Casing

Functions, variables, and objects written in JavaScript should be created using camelCase capitalisation (the first word is in lower case, and any additional words in title-case eg: setModifiedFlag()).

For inherited components, however -- "core XML", exposed engine functions and built-in JS commands -- their own casing will of course need to be maintained in order for the commands to be recognised. These tend to be camelCase or lowercase for the most part. Endeavouring to use camelCase where possible should provide a reasonable middle ground.

Example of conventional scripted casing:

  <object name="exampleObject"
          style="myStyle"
  >
          <action on="Press"><![CDATA[
                 guiHide (this.name);
          ]]></action>
  </object>

Formatting

  • Use the "Good Bracketing" specified in Coding Conventions ({ } are horizontally aligned).
  • Use meaningful comments and variable names.
Note: See TracWiki for help on using the wiki.