


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
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
1 / 4
This page cannot be seen from the preview
Don't miss anything!



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?