Changes between Initial Version and Version 1 of GUI_-_Coding_Conventions


Ignore:
Timestamp:
Feb 23, 2008, 4:19:00 AM (16 years ago)
Author:
trac
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • GUI_-_Coding_Conventions

    v1 v1  
     1= Overview =
     2
     3Where possible, we should endeavour to share [wiki:Coding_Conventions Coding Conventions] with the engine programmers.
     4
     5= Naming Conventions =
     6
     7Use 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.
     8
     9Technically, the hyphen or dash (-) can be used interchangeably with hyphens, but you'll need to reference the string in a different way:
     10
     11{{{
     12  object.cell_id
     13}}}
     14
     15is exactly equivalent to
     16
     17{{{
     18  object["cell-id"]
     19}}}
     20
     21For consistency, though, it's best to just stick to alphanumerics and underscores.
     22
     23= Variable Casing =
     24
     25Functions, 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()''').
     26
     27For 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.
     28
     29Example of conventional scripted casing:
     30
     31{{{
     32  <object name="exampleObject"
     33          style="myStyle"
     34  >
     35          <action on="Press"><![CDATA[
     36                 guiHide (this.name);
     37          ]]></action>
     38  </object>
     39}}}
     40
     41= Formatting =
     42
     43 * Use the "Good Bracketing" specified in [wiki:Coding_Conventions Coding Conventions] ({ } are horizontally aligned).
     44 * Use meaningful comments and variable names.