Author: Amir Ban
Date: 07:25:25 11/05/97
Go up one level in this thread
On November 05, 1997 at 06:23:36, Bas Hamstra wrote: >Hi Amir, > >Congratulations with your victory. > Thank you kindly. >I'm doing some C++ in a chess program but I am more used to C. > >You once said that in Junior you use only ONE class: position. Now I >don't understand that. It seems to me that if you have exactly one class >you might as well code your program in C in stead of C++. Could you >comment on that, please? > I don't recall saying there is one class only, but it is true that the Position class is the main one. I have no idea why a single-class program is not truely object-oriented (if that's what you mean). Why not ? >Further I would like to hear your opinion on the following. I plan to >use the following objects: > >- TBoard (including make/unmake) >- THashTable >- TMovGen >- TDragDrop (graphical stuff) >- TSearch >- TEval > >Now this looks like a bunch of modules in a C program to me. Is it >reasonable to set up objects this way or am I on the wrong track? > You realize that I can comment only generally, not knowing exactly what you have in mind, but I have this comment: Prefereably your objects should be THINGS, not ACTIONS, and as concrete as possible. The actions are what you do on the objects, they are not the objects themselves. If your object names sound like nouns, you are doing OK. If they sound like verbs, you may still be thinking in a non-OOP way. So TBoard and THashTable sound OK, but the others perhaps not. >BTW: All objects are to be created exactly ONCE, just like globals in a >C program, and dynamically allocated from the heap. This is quite possible, but a useful class usually gets instantiated several times. Maybe it's best to think of classes simply as types (which is really what they are). Think of your classes as you think of 'int' and 'char'. In a C program, would you make an effort to use 'int' only once ? There is also no special reason to allocate from the heap. All other ways of declaration are possible, and it all really depends on what you want to do with your objects. > For the graphical >object I plan to create a totally customizable graphical chess board >dragdrop component (a visual object that can be dropped on a form in a >visual environment like Delphi/C++ Builder). > >Comments very welcome. > > >Regards, >Bas Hamstra. Best of luck, Amir
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.