Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Use of objects and associated performance hit?

Author: Daniel Clausen

Date: 05:52:00 12/31/99

Go up one level in this thread


Hi

On December 30, 1999 at 18:53:04, Tom Kerrigan wrote:

>Although I love C and I usually don't approve of object-oriented programming, I
>think there are compelling reasons to use objects in a chess program.
>
>Specifically, I want to have a chess board class, which contains the data and
>functions necessary to manipulate a chess board. I also want to have an engine
>class, which extends the chess board class, and adds the functions necessary to
>search the board.
>
>I have two questions:
>1. When I access the chess board class from the engine class, will there be a
>performance hit?
>2. If I have multiple instances of the engine class, can each one run on a
>different processor without a performance hit?
>
>Thanks,
>Tom

If you have a board-class and your engine-class extends this board-class,
then the engine-class doesn't HAVE one board but your engine IS a board.

A lot of people tend to 'solve' a lot of problems by sub-classing - and in the
end they end up with a rather silly/strange design. If I understood you
correctly, you want to accomplish that your engine has a board, which sounds
like a simple attribute to me. (value- or reference-contained possible)

As a rule of thumb, whenever you create a class B which derives from class A,
you should ask the question "Is B an A?". If you can't answer this with a clear
'yes', something is suspicious. And in my opinion an chess engine is simply not
a chess board.

Kind regards,
 -sargon

PS. http://www.cl.ais.net/brianw/HumorKang.html to see what could happen
   if you sub-class in a funny way. =)



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.