Changes between Version 49 and Version 50 of Coding_Conventions
- Timestamp:
- Apr 11, 2020, 11:35:05 AM (4 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Coding_Conventions
v49 v50 348 348 * 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.) 349 349 350 * W e'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.M AX_PREFERENCE_BONUS= 2;`).350 * When using Class syntax for JS: 351 * Literals are stored in the prototype (e.g. `BuildingAI.prototype.MaxPreferenceBonus = 2;`). 352 352 * 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 355 class Example 356 { 357 Init() 358 { 359 this.value = 0; 360 } 361 } 362 363 Example.prototype.Schema = 364 "<empty/>"; 365 366 Example.prototype.MaxValue = 2; 367 368 Engine.RegisterComponentType(IID_Example, "Example", Example); 369 }}} 354 370 355 371 * Don't omit the optional semicolons after statements.