1. Don’t write sql queries inside a page, rather write as a function of a class.
2. Do not write functions in a general page, rather write as a class function.
3. Do not require or include extra pages and do not write any extra code. If you are
using copy-paste also try to remove extra codes.
4. Try not to bother built in functionalities and to use already defined functions or
css classes as much as possible.
5. No need to re-declare already declared variables as global.
6. Except some situation no need to define a variable.
7. Do not write strings (i.e, error notice) in a page, rather use language file so that if
there is a sudden requirement of multi lingual site no need to change the code.
In JavaScript file language can be added as
SUGAR.language.get(‘Reports’, ‘LBL_BLANK_MODULE’)
or
SUGAR.language.get(‘app_strings’,'LBL_LOADING_PAGE’)
8. Maintain Class and module name convention. (i.e, module name is ended with ‘s’
or plural, any other file inside the module is singular, Class name is also singular)
9. Write functions name in such a way that anyone can have a clear idea of what will
be the functionality of that function.
10. If some functionality is getting used many times in different module or pages, try
to write that in a common place as a common function or common class function
(may be in include/utils.php or module/module_name/class_name.php)
11. General convention:
a. If you want to write a function related to a module, write the function in
that module class file.
b. If you want any functionality which you need inside any module and that
functionality is related to some database operation, write the function in
‘data/SugarBean.php’.
c. If you want any functionality which you need inside any module and that
functionality is not related to any database operation, write the function in
‘include/utils.php’.