mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-13 01:02:58 +00:00
46 lines
1.5 KiB
Plaintext
Executable File
46 lines
1.5 KiB
Plaintext
Executable File
Coding standards and advice for iD
|
|
==================================
|
|
|
|
Classes
|
|
-------
|
|
All constructors must initialise objects and arrays. It is not enough to say
|
|
array:[],
|
|
constructor:function() {
|
|
},
|
|
|
|
but rather, you should do
|
|
array: null, // effectively a placeholder
|
|
constructor:function() {
|
|
this.array=[],
|
|
},
|
|
|
|
or bad things will happen. You should still declare the object outside the constructor, but for clarity rather than functionality.
|
|
|
|
(This doesn't apply to simple types - numbers, strings, booleans - which you can declare as normal.)
|
|
|
|
Function names
|
|
--------------
|
|
Anything that creates and calls an Action should be prefixed with do:
|
|
doSetLatLon(lat,lon)
|
|
Anything that is called by an Action, to do the actual work, should be prefixed with an underscore:
|
|
_setLatLon(lat,lon)
|
|
and commented as such.
|
|
|
|
File naming
|
|
-----------
|
|
The filename should be the name of the base class. You can add subclasses within that file for clarity. Don't add extra classes that aren't subclasses, unless they're not referenced from elsewhere.
|
|
|
|
Class and variable names
|
|
------------------------
|
|
You can prefix function arguments with an underscore to make it clear where they've come from.
|
|
|
|
Layout
|
|
------
|
|
* Hard tabs, indent of 4.
|
|
* Do not indent the root level of the module. Add an 'End of module' comment instead.
|
|
|
|
Useful stuff to know about Dojo
|
|
-------------------------------
|
|
* The array and lang modules are full of useful add-ons to basic JavaScript functionality. lang/hitch will save your life with scopes.
|
|
|