Video 1:

4 types of errors:

1) logic error – mistake in an algorithm where it behaves in an unintended way
2) syntax error – mistake where rules of program arent followed

  • this could be a typo, or a missing character/line
  • common examples: forgetting colons, parenthesis/curly or square braces, indentations, quotes..
    3) run-time error – error that comes up while the program is running
  • program starts to run but then crashes and can not finish
  • also known as a bug
  • may happen because of dividing by 0, inappropriately entered data type (a number instead of a word), or other types
    4) overflow error – error that happens when the computer tries to run a number outside defined range of values
  • because of memory constraints, some numbers are too big for a program to handle (imagine a calculator that has only a 4 digit display – 100*100 would not be able to be displayed)

-> errors will always happen when coding no matter what, and should be an expected part of programming
-> good programers can identify what type of error it is and act accordingly

Video 2:

good ways to find and correct errors:

  • test cases
  • hand tracing
  • visualizations
  • debuggers
  • adding extra output statements

what to do once an error has been found:

-> easiest error to correct is a syntax error – traceback info states which line the error is happening (though sometimes a little more searching is needed)

-> logic errors are much more difficult – in this case, test cases are helpful

  • test cases: using specific, varying inputs to test whether the input works, and to find where the problem is

grade <– INPUT(“enter a grade”)
if (grade > 89) {
DISPLAY (“A”) }
if (grade > 79) {
DISPLAY (“B”) }… etc

good test cases would be numbers within those intervals – also consider: would decimals work? What about negative numbers?

Hand tracing (most useful for loops): writing out the values of the variables of a loop as the loop iterates

  • useful for a loop that repeats a small number of times
  • larger loops need a debugging program

Adding extra output statements:

  • used to help find errors
  • once the error is corrected, the extra output statements are usually removed
  • similar to hand tracing but makes computer do most of the work

If all the above strategies fail:

  • visuals and debuggers can sometimes be used
  • visualizations: graphs, images, colors (or anything else that can be seen) that can show whether or not the program is working
  • debuggers: software designed to test programs – can be paused in the middle of running to test whether that section is working correctly

Video 3:

  • programmers start thinking about testing as soon as they start programming
  • ask yourself: “how will I know the program is working correctly?”

  • programmers have defined inputs to check whether or not the program is working

testing is a cycle of testing and refining