Naming conventions for Tables in Openbravo

Rush of blood – That’s what happens when a raring-to-go developer meets a great development tool/framework. That’s what I felt when I started working on Openbravo. Its so easy and interesting to create whole new modules in no time.

Most often its easy for developers to forget convention when experiencing the rush of blood. In frameworks where convention matters, forgetting them results in spending extra hours getting something to work, which should have been a piece of cake in the first place.

Here’s my checklist on naming tables in Openbravo

1. The Name of the Document should be in camel case and also should begin with the module’s prefix and should not include blank spaces (REST web services cannot be created) .

Eg. The table c_orderline can be written as “C_OrderLine”

2. Description is a must. ¬†Use name if you can’t think of an appropriate description right then.

3. Go for those helps/comments, that comes in handy for future reference. The grand daddies of software don’t swear by documentation for no reason!

4. The java table name should always be in lowercase. (since postgres is not case sensitive its better to use lower case)

5. The view option should be selected only for views/read only tables. Once you mark an Openbravo table a view, they cannot be accessed through REST web-services.

6. The java class name should also be camel cased.

7. Data access level should be set accordingly.

* System only: Only system records can be inserted into this table (AD_CLIENT_ID=0, AD_ORG_ID=0), for example AD_TABLE.

* System/Client: System or client specific records can be inserted here (AD_CLIENT_ID=anything, AD_ORG_ID=0), for example AD_ROLE

* Organization: Only client and organization specific data can be inserted into this table (AD_CLIENT_ID<>0, AD_ORG_ID<>0), for example C_INVOICE

* Client/Organization: Only client specific data can be inserted here, however, it can belong to a specific organizations within that client or be shared among

all (AD_CLIENT_ID<>0, AD_ORG_ID=anything), for example C_BPARTNER

* All: Any combination of AD_CLIENT_ID and AD_ORG_ID can be inserted into this table.

For further information regarding table creation in Openbravo refer