Re: Design: Custom Exception Usage

Tech-Archive recommends: Fix windows errors by optimizing your registry



"Anthony Jones" <A...@xxxxxxxxxxxxxxxx> wrote:
"Peter Duniho" <NpOeStPe...@xxxxxxxxxxxxxxxx> wrote:
I wouldn't want that at all. If I'm calling CanParse(), 99 times out of a
100 it's because I want to parse the string. It'd be silly to call a
method that basically has to do the work of parsing the string, but which
only returns a flag telling me if actually parsing the string will work.

Well thats the crux of the matter isn't it? Why is it "silly" ?

Apart from anything else, I would point out that the "try it and see
if it worked" strategy is more general than the "look before you leap"
strategy. For example, when opening a file, no amount of checking
whether the file is there and whether you have appropriate permissions
will be sufficient to ensure that opening the file succeeds. So even
if you encourage "look before you leap" where possible, people will
still need to be familiar with "try it and see if it worked" for
reasons that have nothing to do with performance and everything to do
with correctness.

Regards,
Weeble.
.



Relevant Pages