foam3

FOAM3 Coding Style Guidelines

Except where noted below, FOAM conforms to the Google Javascript Style Guide. Java code should abide by the Doug Lea Java Code Standard

Exceptions

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;

Naming

Modelling

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 Length

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.

Calling DAO’s From Java

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);

Other

Comments