Chapter 21

Debugging Your Application

Unless your application is extremely simple, it's likely that it'll have a bug or two in it at some point in time. In fact, the more complex the application, the greater the likelihood that it contains bugs. No matter how carefully you code your application, bugs are likely to slip in unnoticed (and definitely unwanted). As a consequence, you'll spend some amount of time debugging your application, which is removing the bugs.

Fortunately, IDEA provides you with tools to locate and squash bugs in your application. Bug removal isn't automatic, but it's possible with a little time and effort using these tools. The following sections describe the kinds of bugs you'll encounter and the techniques you can use to find them. Once found, fixing a bug is as simple as making a small change to your code.

Understanding the Kinds of Application Errors

Before you go any further, it's important to understand that all application writers have problems with bugs. It's not just the novice who experiences problems with bugs—everyone sees a bug now and then. It's true that experience does help to reduce the number of bugs, but bugs are simply part of writing an application.

Bugs can happen in a number of ways. Some bugs are relatively easy to fix, while others require considerable effort on your part to locate and fix. The following sections describe four kinds of bugs that you'll encounter when writing applications of any type.

Considering Syntax Errors

A syntax ...

Get Mastering IDEAScript: The Definitive Guide, with Website now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.