The Open For Business projects follows the Sun coding standards for Java source code.
For information regarding this standard please visit http://java.sun.com/docs/codeconv/html/CodeConvTOC.doc.html
HTML code should be XHTML compliant. Groovy files should follow the same convention as Java files.
In accordance with this standard we use 4 space indention rather than tabs, and set the tab size to 8 spaces to make code with tabs easier to pick out. Make sure no code contains tab characters.
For XML/HTML/FTL files we follow the standard XML/HTML/FTL format (TODO: add link to a reference here). XML/HTML/FTL files should use 2 spaces instead of 4, but there are still number of files using 4 space indention. SO it's better to keep the indentation used in each file to avoid confusion when committing.
We don't want tab characters in text files in SVN, because different editors and tools interpret tabs differently. All indentation should be done purely with spaces.
To change tabs to spaces in Eclipse, change these preferences in Window -> Preferences ->
In Eclipse, for Java, you may use Ctrl+I to be sure of correct indentation.
Entities are named in accordance with the Java naming conventions for classes (e.g. ExampleEntity).
The physical database names are generated by the system by applying the Java naming convention of constants to the entity names (e.g. ExampleEntity => EXAMPLE_ENTITY).
Important: database table names should never be longer than 30 characters, so you have to keep this in mind when you define a new entity name.
For example: the entity name "AnExampleOfALongEntityName" (that is is 26 characters long) is transformed into the database table name AN_EXAMPLE_OF_A_LONG_ENTITY_NAME, that is 32 characters long and exceeds the maximum length of 30 characters and so it is not a good choice.
Entity fields are named in accordance with the Java naming conventions for fields (e.g. exampleField). They have the same length constraint than above : 30 characters max (including "_" separators)
TODO: pk/fk names (including maximum length)
Foreign Keys names have a length constraint of 18 characters (including "_" separators). It's better to set them by hand, to avoid indesirable effects. These constraints do not come from OFBiz but from some DB. To be able to use any DB those constraints should be respected to allow DB portability.
TODO: view-entity names and conventions
Apache OFBiz Best Practices Guide
Each and every source file should contain the ASL2.0 header:
http://svn.ofbiz.org/svn/ofbiz/trunk/APACHE2_HEADER
Adding author information to source files (.e.g. using the @author tag) is a discouraged practice: clearer information about the contributors of a file should be derived from the commit logs.
TODO: controller's request and view naming conventions
TODO: conventions for screen names (top-level screens, included screens, decorators)
TODO: conventions for form names
TODO: conventions for menu names
TODO: conventions for artifacts names such as ftl templates and bsh scripts