Home > Articles > Programming > .NET and Windows Programming

Debugging 101 for Visual Studio

  • PrintPrint
  • Share ThisShare This
  • DiscussDiscuss
Close Window

Peter Aitken

Learn more…

Debugging 101 for Visual Studio
Sep 15, 2006
Fun with Fractals in Visual Studio .NET
Aug 11, 2006
Exploring Excel Functions, Part 9: Analyzing Frequency Distributions
Aug 4, 2006
File Management in .NET
Jul 7, 2006
Exploring Excel Functions 8: Predicting the Future
Jun 30, 2006
Exploring Excel's Functions, Part 7: Rounding with Excel
Jun 23, 2006
Binary File Access in the .NET Framework
Jun 16, 2006
Text File Access in the .NET Framework
Jun 2, 2006
Using Geometric Transforms for Text Effects in .NET
May 26, 2006
Understanding MDI Applications in .NET
May 12, 2006
A .NET Framework Text and Font Primer
Apr 21, 2006
Exploring Excel's Functions, Part 6: TTEST() Function
Apr 14, 2006
Troubleshooting Excel PivotTables
Apr 7, 2006
Troubleshooting Word Tables
Mar 31, 2006
Exploring Excel's Functions, Part 5: The Power of Choice
Mar 24, 2006
Seven Things I Hate About Word Printing
Mar 10, 2006
Exploring Excel's Functions, Part 4: Database Functions
Feb 24, 2006
Exploring Excel's Functions Part 3: CELL() Shocked
Feb 3, 2006
Exploring Excel's Functions Part 2: ADDRESS() and INDIRECT()
Dec 30, 2005
Exploring Excel's Functions: IF() Only!
Dec 9, 2005
Advanced Find-and-Replace Tools in Word
Oct 28, 2005
Going Beyond Basic Spaces and Hyphens in Word
Sep 16, 2005
Get Organized with Word's Outline Tools
Aug 19, 2005
Managing Your Money in Microsoft Excel: Basic Financial Calculations
Jul 29, 2005
Structured Exception Handling in Visual Studio .NET
Oct 8, 2004
Multithreading with the .NET Framework
Jun 11, 2004
.NET Tools for Working with XML
May 21, 2004
Storing Information: Variables and Constants in C
Mar 28, 2003
Introducing Web Programming with .NET
Mar 1, 2002
Using Web Forms
Mar 1, 2002
Introducing Web Services
Feb 15, 2002
XML and the .NET Framework
Feb 8, 2002
ASP.NET Programming: Using Web Forms
Jan 25, 2002
Understanding the Common Features of Web Controls
Aug 20, 2001

Sorry, this author hasn't posted any blogs.

Microsoft Visual Studio 2005 Unleashed

Like this article? We recommend
Microsoft Visual Studio 2005 Unleashed

Every programmer wants to create applications that are free of bugs. In this article, Peter Aitken explores the debugging tools available in Visual Studio.

Legend has it that the term bug dates from the early days of computers, when a program malfunction was traced to an insect that had flown into the computer and caused a short circuit. Whatever their cause, bugs are something that you certainly don’t want in your applications! This article looks at some common causes of bugs and the tools in Visual Studio that help you to find and exterminate them.

Be aware that a bug is not the same as an exception. An exception (also called a runtime error) is something that, if unhandled, can stop your program dead in its tracks, such as attempting to divide by 0, access a nonexistent drive, or open a file to which you don’t have rights. A bug is a code error that causes your program to behave incorrectly, such as in the following examples:

  • A financial program that calculates and displays inaccurate results
  • A graphics program that displays elements at the wrong screen location
  • Any program that doesn’t respond properly to user input

Avoiding Bugs

You may have heard the saying, "An ounce of prevention is worth a pound of cure." This goes for programming, too—the best way to deal with bugs is to avoid them in the first place. This is part of the good programming practice that is second nature to many programmers. Here’s a quick review:

  • Use object-oriented programming design as much as possible. The encapsulation provided by classes not only lessens the chance of bugs but makes them easier to find and fix when they do occur.
  • For Visual Basic programs, always use Option Explicit so that variable declaration is required. Not doing so is a major cause of bugs.
  • Divide your code into relatively small and manageable procedures (methods).
  • Use global and public variables only when it’s unavoidable.
  • Use the proper data type for your variables. Use of integer types can lead to rounding errors.

No matter how religiously you follow these guidelines, however, you’ll almost surely run into some bugs in the programs you write. Let’s explore how Visual Studio can help you to find and fix those bugs. You’ll see that these tools focus on two main factors that are involved in essentially all bugs: the path of program execution, and the value of variables.

  • Share ThisShare This
  • Your Account

Discussions

Make a New Comment

You must log in in order to post a comment.

Related Resources

Jennifer  BortelWin FREE iPhone Developer Books and Videos- Introducing @InformIT Giveaways
By Jennifer Bortel on February 5, 2010 No Comments

Apples’s recent iPad announcement made our hearts flutter so we couldn’t resist making an announcement of our own!

Today marks the first ever @InformIT Giveaway!

We’ll regularly post a video like this one profiling spectacular prizes we’re giving away—from books and videos to T-shirts and other exciting stuff. Check out the video below to see the giveaways for today, and then scroll down for more prize details and instructions on how to win them!

Dustin Sullivan"Every OSX developer should have this book on their desk."
By Dustin Sullivan on February 1, 2010 No Comments

That was the sentence Mike Riley ended his recent Dr Dobb's CodeTalk review of Cocoa Programming Developer's Handbook with.

David ChisnallCocoa Tip of the Day, 1/29/10
By David Chisnall on January 29, 2010 No Comments

Don't ignore old versions of OS X.

See All Related Blogs

Informit Network