Except where noted below, FOAM conforms to the Google Javascript Style Guide. Java code should abide by the Doug Lea Java Code Standard
if, for, while, and switch headers:
if ( a < b ) ...
for ( var i = 0 ; i < words.length ; i++ ) ...
for ( var key in obj ) ...
while ( true ) ...
switch ( argCount ) ...
! operator must be followed by a space.
if ( ! found ) ...
if, while, and for statements that can fit on a single line (less than 80 characters) do not need braces:
```javascript
if ( ! found ) return false;for ( var i = 0 ; i < a.length ; i++ ) a[i] = ‘’;
* The rules about using Closure's `goog.provide`, `goog.require` and similar are
omitted; use FOAM's `requires: []` support instead.
* The rules about using JSDoc comments to inform the Closure compiler's
type-checking are omitted; use FOAM's type-checking instead.
* Encourage the use of vertical alignment where it makes sense, since it makes code easier to read. Ex.:
```javascript
var firstName = 'John';
var lastName = 'Smith';
var age = 42;
this
.addClass(this.myClass())
.start()
.start('p')
.addClass('label')
.add(this.data)
.startContext({ data: this })
.add(this.REMOVE_SELF)
.endContext()
.end()
.end();
Model, Photo, EMail.DAOparent, firstName_). Ex. listeners_NAMES_LIKE_THIS for constant and message names.Code should be modeled rather than created as conventional JS prototypes.
Provide property labels when the default labelization of the property name will not be helpful or attractive to users.
Line lengths should be 80 characters or less, except for embedded data, like templates or sprites, or when modifying the code to make it fit in less than 80 characters would actually makes it less readable.
When implementing DAO strategies in Java, implement the Context-Oriented (CO) methods, ie. those ending with _ and explicitly taking Contexts as the first paramter, like:
find_(X x, Object query).
When implementing DAO decoratores in Java, implement the CO methods and also delegate to the CO method of your delegate. ie.
getDelegate().find_(x, id).
When using a DAO as a regular client from outside of a decorator for that DAO, use the non-CO methods and use inX() to specify the context. ie.
DAO userDAO = ((DAO) x.get("userDAO")).inX(x);
userDAO.find(id);