UsersGuide:Chapter 12:What is Debugging?
From Real Software Documentation
Contents |
What is Debugging?
Debugging means removing errors, both logical and syntactical, from your programming code. Errors in programming code are referred to as “bugs.” You are probably wondering why errors are called “bugs.” Well, back in the 1940’s, the United States Navy had a computer that occupied an entire warehouse. At that time, computers used vacuum tubes and the light from the tubes attracted moths. These moths would get inside the computer and short out the tubes. Technicians would have to go in and remove the bugs to make the computer work again. Since this was a government project, everything had to be logged, so they would put down “debugging computer” in the log. But enough of the history lesson.
Debugging is part of programming. It’s the part of programming most programmers like the least. Fortunately, Real Studio makes it easy to track down those nasty bugs and squash them like a, well, bug. Real Studio comes with a Debugger which is a set of windows that help you see what is going wrong.
Logical Bugs
These are bugs in your programming logic. You will know you have found one of these when your code compiles but does not produce the results you were expecting. Real Studio&squo;s built-in Debugger can help you find these by letting you watch your code execute one line at a time.
Syntactical Bugs
These are bugs where you have mistyped the name of a class, property, variable, or method. You may have also tried to use two values together that don’t go together. For example, if you try to assign a String value to a variable or property of type Integer, you will get a Type Mismatch error because they are different data types.
Analyzing the Project
Since Real Studio cannot compile a project that contains syntax errors, it offers the option of analyzing the project as a preliminary step. Choose Project ↠ Analyze Project or Project ↠ Analyze Item, where Item is the current item in the IDE window. Analyze Project checks for errors and other issues but does not compile the project. Some issues that it identifies are the use of deprecated items and “old style” constructors, unused local variables and parameters, and type conversion issues. If no errors or issues are found, it displays an alert box.
If it finds errors or issues, it opens an Issues screen. The Issues screen reports both the syntactical errors and issues in the same list. It reports one issue per line, even if there are several issues in the same line. You may find that you need to rerun Analyze Project to catch additional errors in a line.
A typical Issues screen with both errors and issues is shown below.
Errors are identified in the left column by the alert icon and issues by the caution icon. You have to fix all of the syntax errors before you can compile the project; The issues are presented for your information and can help you optimize your code. You should take them under advisement and follow their recommendations when appropriate for your project.
In this view, the results are organized by error/issue. To the left of the icon, there is a disclosure triangle. This is because there may be several instances of an error or issue. Click the disclosure triangle to reveal the instances of that bug or issue.
The expanded view of the “missing ‘Then’ keyword” error is shown in the above illustration. It shows that there’s one instance of that type of error. The line of code containing the error is shown; double-click it to go to the Method Editor containing the bug.
Viewing the Issues screen by Method
The default view of the Issues screen presents the items organized by error/issue. You can also view the items organized by method. In this view, each item is a method and the disclosure triangle reveals all the errors/issues that Analyze Project found in that method. You control the display via the icons in the Issues toolbar.
The errors/issues icon organizes the results as shown in the above section. The Pushpin icon denotes the listing by the method that contains the error/issue. The following illustration shows the same results organized by method.
When you expand a method, you see all the errors/issues that were found in that method. This illustration shows the method that contains the “missing ‘Then’ keyword” error.
Filtering Types of Issues
You can control the types of issues that the Issues screen will report. Clicking the “Type Filter” button in the Issues toolbar will display a dialog box that lists all the types of issues that it will check. Only the selected issues are reported. If you don’t want to receive reports concerning a particular issue, deselect that issue.
For example, the Analyze Project system is reporting that an Event Parameter is not used. This project does not have to use that parameter in order to function properly. If you don’t want Analyze Project to check for that issue, you can deselect the “Item1 is an unused event parameter” item. When a type that was deselected occurs, then the Issues tab contains the note “(hidden)”. But it does not list the error.


