Author: Russell Reagan
Date: 11:06:56 08/11/04
Go up one level in this thread
On August 10, 2004 at 12:01:29, Tord Romstad wrote: >They probably would. I prefer the plain C version, though. Chess programs >are typically rather small and simple programs, written by a single person >rather than a big team. In other words, it they are precisely the kind >of programs where the advantages of OOP aren't really very important. >There are probably cases in a chess program where using classes would be >slightly more convenient or elegant, but I think the difference is not big >enough to matter much in practice. Sticking to ANSI C ensures that the >program is more easily portable to a wide range of platforms (C compilers >are still more widespread than C++ compilers, I think), which, at least >to me, is more important than the very minor advantages switching to C++ >would buy me. I use classes for almost all of my data now. My goals are: 1. Initialize the data to a valid state 2. Maintain the data's valid state 3. Automatic notification when something is broken This has saved me months of time in debugging. Problems I used to spend days or weeks tracking down now pop up automatically. If I compile with a debug flag, every class will do automatic, internal error checking. To me the advantage of using classes is not minor at all. To me it is very major. I doubt I would still be involved in chess programming if I hadn't switched to this approach. It is not slower, and it allows for better optimization opportunities later on. The only downside is that I have to write more code to wrap something up in a class and write error checking code and things like that, but at the very least I make progress now, instead of spending weeks trying to track down a bug and end up scrapping the whole thing and starting over from scratch. I am willing to write the extra code to wrap things up in a class. The main issue is that it makes everything easier to grasp mentally. I can focus on one class and understand it completely, make sure it is working correctly, and then not have to worry about that class anymore. I can't do that in a C program where data may be handled (and corrupted) by 100 different functions.
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.