Chapter 11

Exception Handling and Debugging

What you will learn in this chapter:

  • The differences among bugs, errors, and exceptions
  • Syntax, semantic, and logic bugs
  • Exception handling
  • Throwing exceptions
  • Using the debugger
  • Debugging windows
  • Bug detection, isolation, and correction

wrox.com code downloads for this chapter

You can find the wrox.com code downloads for this chapter at www.wrox.com/remtitle.cgi?isbn=9781118336922 on the Download Code tab. The code in the Chapter11 folder is individually named according to the names throughout the chapter.

It would be wonderful if this chapter didn't need to be written. However, the truth is that problems do arise when programs are developed and run.

Most experienced programmers agree that approximately 20 percent of program development time consists of writing program code. The remaining 80 percent is used for testing, debugging, and maintenance of that code. Clearly, anything you can do to reduce that 80 percent figure can help keep you on time and on budget.

Overview

It's common for programmers to lump bugs, program errors, and program exceptions into a single concept. Technically, each of these types of errors is different. Now consider each in a little more detail.

Bugs

A bug is a specific type of error caused by the programmer. Bugs typically fall into one of three general categories:

  • Syntax errors
  • Semantic errors
  • Logic errors

Syntax Errors

A syntax error occurs when a statement does not comply with the rules of the language. ...

Get Beginning Object-Oriented Programming with C# 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.