Understanding The Code

The most important task when working with someone else’s code is to understand what it is supposed to do. Here are some ways to do this:

  • Read the documentation

  • Read the header block for each function

  • Look through the source code, and ask yourself the following questions:

    • What is this class/method supposed to do?

    • What sort of arguments are expected?

    • What type is returned by the method?

    • Can I explain what every line of code is doing?

  • Run it and see what happens!


Debugging means finding and correcting faults in software. Faults are sometimes called bugs. Debugging usually involves three main steps: Observing the fault, locating the fault, and fixing the fault.

  1. Observe the fault

    • Bugs might cause a compile error or a runtime error, these are obvious. More elusive faults don’t produce an error but result in incorrect output. To notice these faults, you must understang what the program is supposed to do. Otherwise, there is no way to tell if it’s producing what you expect!

  2. Locate the fault

    • Some methods to help locate the fault include print statements and the Eclipse debugger. Print statements can be helpful at the end of methods or loops in order to verify that a method is doing what it is intended to do. Printing can tell you what a variable’s value is. The debugger can help when checking if statements and for/while loops to check one operation at a time. Both tools can be used in a variety of ways for debugging. The debugger cah help you determine how a variable got its value.

  3. Fix the fault

    • Sometimes it’s obvious how the fault can be fixed, but sometimes it may take some thought. Print statements and the debugger can help identify how to fix the fault and to verify that it is working correctly after the fix.