Author: David Rasmussen
Date: 02:40:15 01/25/03
Go up one level in this thread
On January 24, 2003 at 18:06:51, Odd Gunnar Malin wrote:
>>- snip -
>>>of my habits, There is many 'if (size<0) return;' etc. in my code, mainly
>>>because I reuse so much.
>>>
>>>Odd Gunnar
>>
>>Is that bad?
>>
>
>Not in general, but to program effective you have to think if the test are ever
>true.
>Ex. from my add to DrawTable where max entries are 1000:
>
>void add(...)
>{
> if (size>=1000)
> return;
> ...
>}
>
>Well, there couldn't ever be 1000 position in there if we are playing legal
>chess.
>
>or when returning under search:
>
>void remove()
>{
> if (size)
> size--;
>}
>
>But when I run my code under boundchecker I don't find any write outside the
>bounds neither :)
>
I would probably throw an exception in such so as to actually know when and what
went wrong, and to have more robust error handling without scattering all my
code with error checking a la C.
/David
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.