CS 261 Lab E - Bug Squashing
Due Wed Feb 19 at 9:00am
Overview
In this lab, you will practice finding and fixing bugs in a class. The class in question is designed to manipulate Strings. It imitates some of the methods of the String class, and adds a couple others. Its class documentation can be found here.
However, as the name implies, Buggy has a few, little, teeny-tiny errors. It crashes, produces incorrect results, hangs, or otherwise fails. Your job in this lab is to fix it. You basically will be testing each of the Buggy methods independently (thus performing unit testing).
This lab will be completed in pairs. Review the pair programming guidelines!
Objectives
- To practice testing and debugging.
- To play with some of the testing tools we've talked about in class.
Necessary Files
You will need to download the copy of the zipped Buggy.java. file and import it into Eclipse.
Details
- Take a moment to look over the class before you begin, to get a sense for what you're getting into.
-
Go through the class and fix all of the errors. That's about it!
- Use a combination of black-box, white-box and boundary testing to discover problems.
- You can use
System.out.println()
,assert
, JUnit, or the Eclipse Debugger to fix the errors. In fact, I recommend you try them all! If you use prints or asserts, don't remove them when you are done--just comment them out so we can see what you did. In other words, there should be evidence of your debugging process! - You will likely want to make a BuggerTester class that has a main() method to help you along.
- Each of the six methods have at least two bugs (maybe more). Gotta fix 'em all!
- Your goal is to make the code as bulletproof as possible. It should work flawlessly!
- Once your code works flawlessly, fill in the class comment at the top to document your changes before submitting the working class to the submission folder. Double-check that your names are on the file!
- Fill out the lab partner evaluation survey after you turn in your work!
Submitting
Submit the fixed Buggy.java following files to the LabE submission folder on hedwig. Make sure you upload your work to the correct folder! The lab is due at the start of class on the day after the lab.
Remember to fill out your lab partner evaluation!
Food for Thought
- Is it easier to write correct code the first time or to debug it later?
- Is it useful if previous programmers adds explanatory comments to the code they write?
- Do indentation, meaningful variable names, spacing and other formatting of code make it easier to read, understand and debug?
- What should we do with people who think: "I ran a couple of tests and everything worked. It must be right."?
Grading
This assignment will be graded based on approximately the following criteria:
- Each method works flawlessly [~15% each]
- The class comment at the top of the file is completed [5%]
- You completed your lab partner evaluation [5%]