Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: OOP - Is this possible?

Author: Russell Reagan

Date: 17:44:11 03/27/02

Go up one level in this thread


On March 27, 2002 at 06:25:12, Arshad F. Syed wrote:

>I plan to write a chess program. I was wondering if it would be worthwhile to
>use the OOP approach. I have visited some sites of chess programs using OOP. The
>general consensus is that OOP would cause a big hit on the NPS. Is it possible
>with some really good programming to write an OOP based program that would have
>the same NPS as the same program written without using OOP?
>
>Regards,
>Arshad Syed

It is certainly possible to do what you ask. OOP does not imply, as many people
assume, that everything must be done dynamically. You can inline methods to
classes, and use static variables where appropriate. If you are experienced in
OOP and know how to use it, you can write your program in such a way that any
loss in speed will not be due to your decision to write it in an object oriented
manner. If you aren't familiar with OOP then you probably won't have the fastest
program, but then again if you weren't familiar with a non-OOP approach you
would get the same result. OOP offers the VERY nice advantage of being able to
change the implementation of how your program works without having to change the
algorithms that act upon the data. You WILL change your program countless times,
and if you prepare correctly in an OO approach you will save tons of time. I've
been working on my program for years, and I have made little progress because I
keep thinking of new ideas and I try to add the ideas into my program, and I
decide that I am better off starting from scratch than try and force the round
peg in the square hole. The other assumption that people make is that OOP is C++
with classes and inheritance and that it's of course all dynamically allocating
memory, and of course those things would cause slight (or maybe significant)
overhead. The truth is you can write in an object oriented manner in almost any
language. I am currently redoing my chess program in an object oriented way in
C. It's really only a matter of how you look at it tackling the project. If it
makes more sense to you to think of a chess playing program in terms of objects,
then go with OOP, because you can certainly do it without causing any overhead
at all if you know what you're doing. So if you know what you're doing, you'll
be fine either way. If you don't know what you're doing, neither OOP nor non-OOP
approaches are going to be drastically better than the other.

Russell



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.