Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: debugging question

Author: Steven Edwards

Date: 21:46:26 08/13/03

Go up one level in this thread


On August 13, 2003 at 11:56:38, Uri Blass wrote:

>There are cases when I make changes that are not supposed to change
>a single global varaible(the changes can be only for speed or only some
>preperation for another change because new function that I write may be used
>later in a different way).

Some suggestions:

1. Don't use global variables.  A quick fix is to define a struct type that
contains all of your currently global sate variables along with read, write, and
compare routines.

2. Consider using C++ instead of C, but don't got locked into any vendor
specific libraries or classes.  With C++, there is ample support for a natural
and good coding style that eliminates the need for global state information.
For example. the current CT toolkit source, all in C++, is about 350 Kbytes of
text with 4,000+ statements, 60+ classes, and zero globals.

3. For each aggregate type, consider writing an IsValid() funtion that checks
for internal consistency.  Use the assert facility to conditionally trigger
these checks; you shouldn't care about the resulting slowdown during debugging
and the assert macros can turn off the code for a production version.



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.