Re: value

new topic     » goto parent     » topic index » view thread      » older message » newer message

Hello Kat,

At 13:33 24/10/02 -0500, you wrote:
<snip>
>What about leading zero stripping, without decimal points? Like:
>value("00000000000000000000000000000000000000000000000001")?
</snip>

My approach to dealing with cases such as these is to make a judgement call
on how likely such a case might be.  If it is likely then check for many
leading zeroes yourself.  If they exist remove them and then pass the
modified argument to the value function.  If you think the case is unlikely
then just pass the argument to the value function.  If it blows up or gives
a bad result then this _should_ show up somewhere along the line.  If the
code is part of a game then sometimes the game might crash.  If the code is
controlling a lathe then the lathe might jam and result in a repair bill of
four figures.  Use your judgement to make the right call.

The concept is if you feel a function isn't robust enough with extreme
inputs (are these called boundary conditions?) then do the "extreme case"
checks yourself before using the function.

<snip>
>I haven't hit this yet, but i can see 
>the possibility of it happening.
</snip>

Very true but you also should make a call on how much defensive programming
to put into an application.  How many of us check to see if a write to a
file actually succeeded?  Disks do run out of space or the permissions on
the file you want to write to can change to deny you write access.

Bad applications do little or no error checking.  Good applications do
enough error checking to catch the "common" error conditions.  No
application can do any amount of error checking to guarantee 100% that the
right result has been achieved.

An experienced programmer (and former boss way back when) said to me that
good programs consisted mainly of code for preventing errors and/or for
handling them.  Personally I think that is still true but everything is
relative.

Regards,

Andy Cranston.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu