[Openbravo-development] Prefixing/Namespacing javascript objects using module prefixes

5 views
Skip to first unread message

Martin Taal

unread,
Jan 4, 2012, 2:10:52 PM1/4/12
to openbravo-...@lists.sourceforge.net
Hi,
When developing in javascript and adding global objects it is good practice to place all the global objects in a separate namespace object. Earlier the recommendatation was to only use the module's prefix as the global object, for example (with the Application Example module's prefix OBEXAPP):
OBEXAPP = {}
;
OBEXAPP.OnChangeFunctions = {};
The recommendation has changed to add the module's global object to the global OB object which already exists:
OB.OBEXAPP = {};
OB.OBEXAPP.OnChangeFunctions = {};
This means that only the OB object itself will be directly globally visible which is nicer/better from a namespace/namecollision point of view.

The changes have been reflected in the documentation:
http://wiki.openbravo.com/wiki/How_to_create_client_side_callout_onchange_function
http://wiki.openbravo.com/wiki/How_to_create_a_Pick_and_Execute_Process
http://wiki.openbravo.com/wiki/Client_Side_Development_and_API#Implementing_global-singleton_javascript_objects
-- 

With Regards, Martin Taal

Openbravo
M: +31 6 288 48 943
@: marti...@openbravo.com
Skype: martintaal

Openbravo Headquarters:
P: +34 93 27 25 947
F: +34 93 27 25 905
Address: Edificio Slan, Planta 2a, Landaben, Calle J, 31012 Pamplona, Navarra, Spain
Mailing address: PO Box 5117, 31010 Pamplona, Navarra, Spain
Reply all
Reply to author
Forward
0 new messages