Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: Is there an overhead in this OO design ?

Author: Alessandro Scotti

Date: 14:44:05 01/06/06

Go up one level in this thread


On January 06, 2006 at 16:22:57, Alexander Kure wrote:

>On January 06, 2006 at 15:06:08, Alessandro Scotti wrote:
>
>>On January 06, 2006 at 12:28:00, Alexander Kure wrote:
>>
>>>>>>>3) Instead of low-levely maipulating a square by means of operator+=() you could
>>>>>>>declare the following high-level functions in class CSquare:
>>>>>>>
>>>>>>>   void Up();
>>>>>>>   void Down();
>>>>>>>   void Left();
>>>>>>>   void Right();
>>>>>>>   void Next();
>>>>>>>   void Previous();
>>
>>>Everything you say is correct but doesn't address the encapsulation issue. By
>>>making IsAdjacent() a member function actually _reduces_ encapsulation!
>>>
>>>I don't think a square should decide if it is adjacent to another square.
>>>Adjaceny is a concept that goes way beyond of the concept of a square and should
>>>therefore be handled somewhere else.
>>
>>Hi Alex,
>>this makes sense but if so then also all of the above functions (up, down, etc.)
>>should be moved outside the class, leaving it pretty short of methods... :-)
>>Maybe it's just better to leave CSquare as int and move this stuff into a
>>CBoard.
>
>
>Hi Alessandro,
>
>Well, the difference is that Up(), Down(), etc. work on the internals of
>CSquare, i.e. change the state of a CSquare-object, thus have to be member
>functions.

Yes, but they have to know the board "geometry" so to speak, and IsAdjacent()
can be espressed in terms of those functions. So there's little to gain from
having some functions in and some other out.
It's difficult to change the internal representation of CBoard if Up(), Down(),
etc. are implemented inside CSquare.



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.