Skip to content

5. Debugging

Bugs are just mistakes, while debugging you should learn from your mistakes and list them.

  1. Write a pseudocode and list all the edge cases.
  2. keep your code splitted into chunks with an explainatory comment on top of each one.
  3. While debugging use comments to disable your code part by part to locate the bug.
  4. List your common bugs.
  5. Dealing with zero-based numbering can be troublesome. You either convert everything entered by input to zero-base (which is prefered) or you resize the array and ignore the first element of the array.

Common bugs

  • Check edge cases.
  • Check ( = / == ) is it boolean '==' or declaring '='.
  • Check position of variables declaration: always declare variables when you'll use them immediately.