-
Notifications
You must be signed in to change notification settings - Fork 266
X:style
haehn edited this page May 15, 2012
·
10 revisions
XTK coding style draft
- use camelCase for variables and functions
var topLevelObjectsLength = 0;
X.renderer.prototype.resetViewAndRender = function() {..}
- class names are lowercase (with events as an exception which are upper-camelcase)
- 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
- All properties start with an underscore _
- Only protected properties
- To make properties public, use a getter/setter mechanism and remove the underscore '_'
/** * Get the className of this object. * * @return {string} The className of this object. * @public */ X.base.prototype.__defineGetter__('className', function() { return this._className; });
- Protected properties (will be renamed during optimization)
this._objects = new X.array();
- however you like
- decrementing while loop is faster than for
- Fast Duff's Device is the fastest but takes more lines of code