Changes between Version 49 and Version 50 of Coding_Conventions


Ignore:
Timestamp:
Apr 11, 2020, 11:35:05 AM (4 years ago)
Author:
Freagarach
Comment:

Inline example instead of link.

Legend:

Unmodified
Added
Removed
Modified
  • Coding_Conventions

    v49 v50  
    348348 * Use roughly the same Doxygen-style comments for documentation as described above for C++. (But we don't actually run Doxygen on the JS code, so there's no need to make the comments use technically correct Doxygen syntax.)
    349349
    350  * We've recently been switching to Class syntax for JS (see e.g. [https://code.wildfiregames.com/P169]).
    351    * Literals are stored in the prototype (e.g. `BuildingAI.prototype.MAX_PREFERENCE_BONUS = 2;`).
     350 * When using Class syntax for JS:
     351   * Literals are stored in the prototype (e.g. `BuildingAI.prototype.MaxPreferenceBonus = 2;`).
    352352   * The Schema is also a literal and hence is stored in the prototype.
    353    * We don't want to rewrite components just for the sake of it, but new components should be written in the class syntax and major rewrites can opt to use the class syntax.
     353{{{
     354#!js
     355class Example
     356{
     357    Init()
     358    {
     359      this.value = 0;
     360    }
     361}
     362
     363Example.prototype.Schema =
     364    "<empty/>";
     365
     366Example.prototype.MaxValue = 2;
     367
     368Engine.RegisterComponentType(IID_Example, "Example", Example);
     369}}}
    354370
    355371 * Don't omit the optional semicolons after statements.