-
Notifications
You must be signed in to change notification settings - Fork 266
X:style
haehn edited this page May 7, 2012
·
10 revisions
XTK coding style draft
- if possible, always inherit from X.base - this enables the event system
- each class has a className attribute (for duck typing and down casting)
/** * @inheritDoc * @const */ this['className'] = 'renderer';
- export symbols (only methods/functions) to avoid optimization by the compiler but only as little as required since it blows up the library size
- Only public or protected properties
- Public properties replace simple getters like this (which avoids optimization by the compiler):
this['container'] = _container;
- Protected properties (will be renamed during optimization)
this.objects = new X.array();
- always start with a underscore (_)
- decrementing while loop is faster than for
- Fast Duff's Device is the fastest but takes more lines of code