Article

From:
To:
Raoul De Kezel
Subject:
Re: Exceptions vs Error codes
Newsgroup:
borland.public.delphi.objectpascal

Re: Exceptions vs Error codes

"Raoul De Kezel"
<‚úČhotmail.com> wrote in
message
news:MPG.15e0fcd333d3013e989730@forums.i
nprise.com...
>
> The paper is available at
ftp://ftp.cs.ucsd.edu/pub/team/exception
handling.ps.Z
>

Raoul,

I've taken some time to read that paper and although I skipped some of the more mathematical parts of it, it *did* give me a refreshing perspective on the issue of exceptions. Here's one highlight: <quote, p.28> The notion of an exception is defined [...] to mean "impossibility of obtaining the specified standard service". It therefore depends on how the states of a program are defined and how the standard service of that program is specified." </quote> My interpretation: The designer of a program, or function, or block of code, *implicitly* determines the criteria for raising exceptions; this is because the purpose of the exception is to:
a) signal impossibility to produce a normal correct result b) prevent the program/function/code block from returning an invalid result which will screw up the rest of the system
The important factor here being accurate *specification* of the behaviour of the code, both for nominal and failure cases. Also, an important point in this article is that free propagation of exceptions across the call stack is a threat to program stability unless you are able to recover states in your intermediate objects (or your objects are stateless). The same cannot be said of error codes since they do not automatically propagate.
Kristofer
FYI: Phrase searches are enclosed in either single or double quotes
 
 
Originally created by
Tamarack Associates
Tue, 07 Feb 2023 05:48:03 UTC
Copyright © 2009-2023
HREF Tools Corp.