No Title

[ A silence falls across the room as I realize that Joel has written something I disagree with entirely. [via ]{style="FONT-STYLE: italic"}[The .NET Guy\< ?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />]]{style="FONT-SIZE: 12pt"}

[\< ?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />I'm with Brad ".NET Guy" Wilson on this. Joel compares exceptions to gotos and not just with the obligatory "considered harmful" phrase, but by comparing them to "gotos sprinkled throughout your code." Now, I don't think that Exceptions-As-Know-Them are the ultimate solution, but comparing them to gotos [and]{style="FONT-STYLE: italic"} invoking "Go To Statement Considered Harmful" is a particularly poor choice. Most people think that Dijkstra damned gotos because they introduce multiple entry points into a code block (i.e., they allow spaghetti). Not at all. In fact, what he complains about is that a goto makes it "terribly hard" to know the state and history of a program's execution ("we can interpret the value of a variable only with respect to the progress of the process .The unbridled use of the *go to* statement has an immediate consequence that it becomes terribly hard to find a meaningful set of coordinates in which to describe the process progress ." ). ]{style="FONT-SIZE: 12pt"}

[With exceptions as implemented in Java and .NET, this is precisely not true. One of the most common complaints when teaching Java or .NET exceptions is "Why are my variables out of scope in the catch (or finally) block?" The reason is precisely that during exception handling, the history of the program is effectively guaranteed to the beginning of the exception scope and the stack-trace gives you most of the information you need to determine the location in code and history that led to the error (what Dijkstra calls the "coordinates" of the program). It's true that without catching the exception in a debugger that lets you walk up the call stack, you can have some difficulty determining when your error was produced (e.g., the exception doesn't tell you that the invalid value came from the 23rd position in your array), but in general, structured exceptions a la Java and .NET are markedly superior for precisely the reason that Dijstra disliked gotos: rapid determination of the state and history of the process leading to the current situation.]{style="FONT-SIZE: 12pt"}