Daniel T. wrote:
"joe" <jc1996@att.net> wrote:
I don't see how you could. If you consider "bug" and "error" to be
the same thing, then what do you call those things that return codes
and C++ exceptions are used for?
To borrow from Bertrand Meyer, we have three notions. The function
succeeds, the function fails do to a precondition violation, and the
function fails do to a postcondition violation. This discussion
pertains to the latter two.
A function can easily detect a precondition violation, but it can't
know what to do in order to fix the problem, that's the job of some
higher level. So for this kind of problem, an exception (or return
code if exceptions aren't used) is the correct option.
A function can't detect a postcondition violation; if the
postcondition is violated (when the precondition was met,) then the
programmer did something wrong. An exception shouldn't be thrown in
this case, the programmer should fix the code instead.
I know "precondition violation" and "postcondition violation" are not
as sexy as "bug" and "error," but that's how I roll I guess. :-)
Yes, that's all good stuff... but, ... um, what is your point? I mean,
issue at hand: "bugs" vs. "errors". Probably because bringing in the
DETAIL terms like "pre/postcondition" doesn't help things in that regard.
thread in these newsgroups ON TOPIC (i.e., the thread topic). Funny I
should say that, since certainly this "bugs vs. errors" thing is a
subtopic (!?).