Good programming practices will help you reduce the probability of introducing errors to your program as well as track them more easily. It will also greatly helps other programmers or developers to understand better what your program is all about. This is some better approaches when you code something in your program.
It is very crucial to comment on what you are trying to do and what you are trying to achieve in modules. This will make it easier if other programmer trying to update or improve your code. Some information that you need to include in your comment
- Name of the module.
- Purpose of the Module.
- Description of the Module (In brief).
- Original Author
- Authors who modified code with a description on why it was modified.
- Naming Conventions
Use descriptive string when you declare variables.
You need to make your code as dynamic as possible so it can be deploy in any environment. Make sure not to hardcode sitename, filepath, user, or any URLs.
Indentations help to format your code to make it easy to read and understand. Poorly formatted code will introduce confusion.
For more infos on good programming practice, click here, articles from phusewiki.org.