Game Development Reference
In-Depth Information
chapter 14
Best Practices for
Robust Exception
Handling
Computers allow you to make more mistakes faster than any other invention
in human history with the possible exception of handguns and tequila.
Mitch Ratcliffe
In the development world, it is nearly impossible to write bug-free software. The
best we can do is write stable software that, when a problem occurs, displays
enough information to solve it. There is no way to write software that is bug-free,
but by employing exception handling, at least we can gracefully handle any anom-
alous situations that occur.
An exception can be defined as unexpected behavior or an error condition occur-
ring in a software application. The name itself comes from the idea that, although
an error condition can occur, the error condition occurs infrequently. The major-
ity of a developer's time is spent on user input and error handling. Thankfully,
there is some functionality in the .NET Class Framework that provides error han-
dling, but there are certain best practices that should be followed in terms of
design concerns and performance issues.
Many developers misuse or overuse exception handling, and this chapter is all
about best practices for using .NET exception handling. This chapter is not centered
on the design aspects of user interface integration, but rather serves to enlighten
readers about the proper way to handle errors while aiming for maximum perfor-
mance and adherence to framework guidelines.
143
Search Nedrilad ::




Custom Search