mirror of
https://github.com/FoggedLens/iD.git
synced 2026-02-12 16:52:50 +00:00
27 lines
1.0 KiB
Plaintext
27 lines
1.0 KiB
Plaintext
Coding standards and advice for iD
|
|
==================================
|
|
|
|
Objects
|
|
-------
|
|
|
|
Most of iD is written with [a js module pattern](http://macwright.org/2012/06/04/the-module-pattern.html):
|
|
that is, they do not use the `new` operator, and they use scope instead of
|
|
`this` to reference variables and functions.
|
|
|
|
The exceptions are classes that are very heavily instantiated: Graphs and entities. These are written in a
|
|
classical manner for [performance reasons](https://gist.github.com/3961693).
|
|
|
|
In order to unify the construction interface for these two styles, classical classes use the
|
|
[instanceof trick](http://ejohn.org/blog/simple-class-instantiation/). This allows instantiation
|
|
of both module pattern classes and classical classes to be done without using `new`.
|
|
|
|
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.
|
|
|
|
Layout
|
|
------
|
|
* Soft tabs
|