Testing and Debugging in CSIS 110: Quiz Results and Assignment - Prof. Brian F. Hanks, Study notes of Javascript programming

The results of a quiz in csis 110, an introductory computer science course, focusing on testing and debugging. The importance of testing and debugging, the difference between syntax and logical errors, and the processes for finding defects. The document also introduces the concept of unit testing and provides an assignment for students to practice testing and debugging.

Typology: Study notes

Pre 2010

Uploaded on 08/05/2009

koofers-user-hn4-1
koofers-user-hn4-1 ๐Ÿ‡บ๐Ÿ‡ธ

10 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
CSIS 110 โ€“ Lecture 33
Quiz Results
Excellent news โ€“ as a class you did much better.
Possible: 25
Mean: 18.6
Median: 20
Max: 24.5
Announcements
Read: Chapter 6, sec 6.1 to 6.3
I have put my versions of the chessboard and histogram projects on the O: drive in the
homework folder if you are interested in looking at my solutions.
Testing
When you work on your methods, does the code that you write work correctly the first
time?
What kinds of things are wrong?
It doesn't compile โ€“ you made a syntax error. For the most part, these are relatively easy
to correct.
It compiles and runs, but produces incorrect results โ€“ your program has a logical error.
These can be much harder to find.
Experienced programmers don't make many syntax errors, and when they do they are
able to correct them quickly. This is because the language details are familiar.
But, they still make logical errors. In a large program it is extremely difficult to write a
program that is 100% correct. Finding and correcting the defects in these programs is a
serious challenge.
What processes can we use to find defects? How do you go about finding problems?
Three activities for improving the correctness of your programs:
Testing: the process of finding out if an application or segment of code (such as a
method) contains a bug. Doing a good job of testing is not easy โ€“ there is much to think
about when testing a program.
pf3
pf4

Partial preview of the text

Download Testing and Debugging in CSIS 110: Quiz Results and Assignment - Prof. Brian F. Hanks and more Study notes Javascript programming in PDF only on Docsity!

CSIS 110 โ€“ Lecture 33

Quiz Results Excellent news โ€“ as a class you did much better. Possible: 25 Mean: 18. Median: 20 Max: 24. Announcements Read: Chapter 6, sec 6.1 to 6. I have put my versions of the chessboard and histogram projects on the O: drive in the homework folder if you are interested in looking at my solutions. Testing When you work on your methods, does the code that you write work correctly the first time? What kinds of things are wrong? It doesn't compile โ€“ you made a syntax error. For the most part, these are relatively easy to correct. It compiles and runs, but produces incorrect results โ€“ your program has a logical error. These can be much harder to find. Experienced programmers don't make many syntax errors, and when they do they are able to correct them quickly. This is because the language details are familiar. But, they still make logical errors. In a large program it is extremely difficult to write a program that is 100% correct. Finding and correcting the defects in these programs is a serious challenge. What processes can we use to find defects? How do you go about finding problems? Three activities for improving the correctness of your programs: Testing: the process of finding out if an application or segment of code (such as a method) contains a bug. Doing a good job of testing is not easy โ€“ there is much to think about when testing a program.

Debugging: when testing shows that there is an error, you have to locate the error in the source code. You need to find out exactly what is causing the error. It can take a significant amount of work between knowing that there is an error and finding its cause. Writing for Maintainability: This is about following practices that lead to fewer errors in the first place. It is also about writing code so that errors are easier to find when they do occur. This is closely related to coding style and documentation. You want your code to be easy to understand โ€“ both for the original programmer and for someone else who might need to read it later. There is a huge difference between well-written an poorly- written code when it comes to debugging effort. [Ask question about what has been done in this class to encourage this practice] For now, we can divide testing up into 2 categories: Application testing and unit testing. Application Testing is testing that examines a complete application (program) for defects. In many cases, the tester does not have access to the code โ€“ all testing is done through the user interface. Unit Testing tests smaller pieces of code (such as a method). Units can be items such as a class, a group of classes, or even a single method. Unit testing can be performed long before the application is complete. Programming Assignment This brings us to our next programming assignment The assignment has 2 parts. The first part is due next Friday, and does not involve any programming! Instead, I want you to test an application that I have written. The assignment is for you to write a program that encrypts messages. [Look at the application and the assignment. Discuss Caesar cipher] How can you go about determining if this program is correct? Well, you could just try random stuff and see what happens. How would you know if the program behaved correctly or not? You need to be more methodical. You need to define some test cases , where you try to verify whether the program behaves correctly for some particular characteristic. To do this, you need to understand what the program is supposed to do. Then you need to check if it actually does this thing.

Create a Day object. Open the object inspector โ€“ does the appointment field have enough elements to store the required number of appointments? Leave the object inspector open. One thing we want to do is make sure that objects behave correctly both when they are empty and when they are full. So, before we create any appointments we should make sure that showAppointments works. Another element of good testing is to check boundaries โ€“ this is where mistakes are often made. What are the boundaries of the Day object?

  • the first appt of the day
  • the last appt of the day Try to create 1 hour appointments at the beginning and end of the day. Also create one in the middle of the day. Use the inspector to make sure the appointments were created. Also call the showAppointments method Are there any other boundaries? Is there anything else we should check at the boundaries? Yes- want to make sure that the method works correctly for values just outside of the boundaries โ€“ make sure the method behaves correctly when you try to make an appointment at 8 or 18. What else should we try? What about double booking? What should happen if we try to make an appointment at the same time as one that already exists? Try it. Did it work? How do you know? Anything else?
  • Does it work when the day is full?
  • What about the other methods?
  • What about longer appointments? Lab Do Exercise 6.8 from the book. Turn in:
  1. A description of each bug that you found.
  2. Your corrected version of the Day class.