4.4 Software Implementation Tips

  • Use examples from documentation
  • Use examples from code
  • Divide complicated task to several simple tasks
  • If the task is complicated - implement simpler task
  • Make a minimal working skeleton of the module
  • Don't optimize before it works
  • Use lookup table for fast calculations
  • Use loop unrolling to speedup execution
  • Use inline/macro to speedup execution
  • Avoid unnecessary inside loop calculations
  • Use shifts for fast division / multiplication.
  • Round integer result by adding 0.5 bit
  • Use structured programming
  • Use coding conventions/rules
  • Don't ignore compiler's warnings
  • Advance slowly on unknown ground
  • Compile during coding
  • Backup your work frequently
  • Write comments before writing code
  • Write remarks as higher level abstraction of code
  • Write pseudo code remarks
  • Avoid unnecessary remarks
  • Write directive remarks (!!!)
  • Write questions remarks (???)
  • Mark code to be deleted (xxx)
  • Remark old code before deleting or changing it
  • Redefine data types for multi platform compatibility.
  • Avoid recursion when memory is limited
  • Pass big objects by reference.
  • Reuse code only when it helps.
  • Prefer using enums over #define
  • Prevent header files from been included several times

 

 

 

  • 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. (U)
  • Compile during coding.
  • Remark old code before deleting or changing it (like recycle bin).
  • Backup your work frequently

    (ctrl+S / autosave / .bak feature / backup to CD or net / VSS / power protector card).

  • Avoid unnecessary inside loop calculations.
  • Write remarks as higher level abstraction of code
  • Write pseudo code remarks (before coding)
  • Write directive remarks (!!!)
  • Write questions remarks (???)
  • Mark code to be deleted (xxx)
  • Avoid unnecessary remarks.

    Avoid long / obvious / over remarking

  • Round integer result by adding 0.5 bit (reduce quantization error - give example log2 - draw graph)
  • Make a minimal working skeleton of the module (optimize and add features later)
  • Prefer enums instead of #define
  • Redefine data types for multi platform compatibility.

    typedef unsinged char UCHAR;

    typedef unsigned long ULONG;

  • Avoid recursion with limited memory.

    Recursion data consumes significant amount of stack memory. Each recursion iteration adds data to the stack. You should avoid using recursion when memory is small.

  • Pass big objects by reference.
  • Reuse code only when it helps.
  • Prevent header files from been included several times

    #ifndef

    #define

    #endif

    or

    #pragma once

     

 

Write how to improve this page

PROGRAMMING TIPS
RAPID TABLES