 Online Reference |
|
PROGRAMMING TIPSRAPID TABLES |
| |
Practical Programming Tips128 Ways to Enhance Your Software Development Skills
Table of Contents3 Developer's Toolbox4 Developer's Tips
Extended Table of Contents3 Developer's Toolbox3.1 Software Tools3.2 Hardware Tools
4 Developer's Tips4.1 General Tips4.2 Specification Tips
4.3 Design Tips4.4 Implementation Tips- Use examples from documentation
- Use examples from code
- Write comments before writing code
- Divide complicated task to several simple tasks
- If the task is complicated - implement simpler task
- Don't optimize before it works
- Use lookup table for fast calculations
- Use loop unrolling to speedup execution
- Use inline/macro to speedup execution
- Use shifts for fast division / multiplication.
- Use structured programming
- Use coding conventions/rules
- Don't ignore compiler's warnings
- Advance slowly on unknown ground
- Compile during coding
- Remark old code before deleting or changing it
- Backup your work frequently
- Avoid unnecessary inside loop calculations
- Write remarks as higher level abstraction of code
- Write pseudo code remarks
- Write directive remarks (!!!)
- Write questions remarks (???)
- Mark code to be deleted (xxx)
- Avoid unnecessary remarks
- Round integer result by adding 0.5 bit
- Make a minimal working skeleton of the module
- Prefer enums instead of #define
- Redefine data types for multi platform compatibility.
- Avoid recursion with limited memory.
- Pass big objects by reference.
- Reuse code only when it helps.
- Prevent header files from been included several times
4.5 Debugging Tips- Problem handling stages
- Find the changes from previous version.
- Review the code.
- Read error description in the manual
- Add an error to the code when checking compilation problem.
- Fix compilation errors by the order they appear
- Use assertions.
- Write validity checks of parameters.
- Check if the problem occurs with previous versions
- Check the platform
- Check if the problem occurs with similar platforms.
- Check if the problem is consistent or random.
- Remark suspected parts of the code and see if problem disappeared.
- Use debugger.
- Build in debug mode.
- Undo recent changes until problem disappears.
- Use binary search to find the problem. (lion in the desert).
- Trial and error. (try several ways and choose the one that works the best)
- Use scope to probe output signal (embedded).
- Consult customer support
- Search internet forums and resources
- Use debug variables.
- Use debug prints
- Check that the source/object/executable files are updated.
- Check the version number. (that you are working with the right version)
- Check that the problem really exist. (bad testing method)
- Use conditional compilation of debug code. (#ifdef DEBUG #endif)
- Rewrite the code
- Common bug: array index / pointer overflow.
- Common bug: casting error in calculation ((float)(a+0.5) - when a int)
- Common bug: if( a=b ) -> (overwrite a)
- Common bug: for(i=0; i<10; j++)
- Common bug: use of local variables instead of dynamic allocation.
- Common bug: cyclic include dependencies.
- Check the compiled asm file (advanced programming)
- Check the map file
- Check memory leaks
- Find a workaround the problem.
- Compare memory section images (good operation vs bad - file compare diff)
- Add conditional breakpoints and prints (if( xxx ) a=a messagebox() )
- Rebuild all
- Fix bugs immediately (stable system / might be related to the bug)
- When problem is not consistent, try to make the problem happen more frequently (increase the suspected problem factors)
- Link error: missing library / missing file in project
4.6 Test Tips4.7 Release Tips4.8 Tools Tips4.9 Documentation Tips
|
|
| | |
 | |  |