Identifying and Correcting Errors 1.4 Notes

Errors

  • errors are a part of coding, they are expected
  • Types of Errors:
    • Logic Errors
    • Syntax Errors
    • Run-time Errors
    • Overflow Errors
  • Logic Errors - make mistake in algorithm, causing the program to behave differently
  • Syntax Errors - making a typo on the code, causing the program to not run (colon/semicolon, parenthesis, braces, indentation, quotes, var def)
  • Run-time Errors - works for a bit and then crashes, caused by a certain line of code in the sequence (called a bug)
    • divide by 0
    • improper user input
  • Overflow Errors - result in certain values that are too big to show or to calculate

How to Correct Errors

  • most syntax errors are shown where in the lines the error is located
    • sometimes are close by
  • logic errors can be solved with test cases (works sometimes but not always)
  • hand tracing - write out values of the variables in the loops
    • used for small code sections, not large ones (use debugging program)
  • adding extra output statements - used to find where the error is (allows computer to show where the error is)
  • visualizations - used to show where the error is with graphs
  • debuggers - allows the user to pause/play the program as is runs

Testing Programs

  • starts with thinking in development on how the program will work
    • use specs to see what the errors are and how it should work
  • when inputs and outputs are determined, the program is tested
    • used to revise and improve program
    • users later continue to test to make sure everything is working
    • mistakes are always found, even after release

Quiz Results: