Following are some of the important points/Best practices that should be taken in consideration while creating a new custom module in drupal.
1) Use underscore “_mymodule_” for private function.
2) Use “ l() ” instead of “<a>text goes here</a>”.
3) Avoid writing all the coding inside a single module file, instead of that you can use .inc files and include them.
4) Use hook_form_FORM_ID whenever possible.
5) Don’t Mix Business PHP code & HTML (Use theming)
6) Avoid Using “SELECT *” in query, instead use “SELECT tablename.*” or “SELECT alias.*
7) Avoid Using SERVER variables ($_GET, $_POST , $_SERVER etc), use DRUPAL API
8) Use Proper Formatting.
9) Add Relevant Comments (file, functions, blocks).
10) Put hook_(un)install, hook_enable, hook_disable and hook_schema in .install file
11) Use placeholders for query arguments.
12) Use theme(‘image’, …) instead of <img … /> tag.
13) Constants must be written in UpperCase.
14) Module constants must start with MYMODULE_. (modulename)
15) Do not use “prefix” & “suffix” with form elements, use theme function (drupal_render()).
16) Include files only when necessary (include_once, require_once, drupal_add_js, drupal_add_css).
17) Remove unused code.i.e Avoid using Dead Code
18) Follow best practices (content type, views, features) = Don’t reinvent the wheel.
19) Avoid Using Pure PHP code, use DRUPAL API.
20) Ensure Permissions are properly used in hook_menu and hook_permission
21) Use tpl files instead of theming functions when writing more than 10 lines of HTML.