Author: Uri Blass
Date: 02:28:36 08/01/04
Go up one level in this thread
On August 01, 2004 at 04:17:35, Volker Böhm wrote: >Hi Uri, > >I read your questions twice but I am still not sure what you are asking for. >Nevertheless I try an answer. > >The "variables" of the class are called "attributes". The "functions" of the >class are called "members" or "member-functions". I will be more specific and I will use the terms that you mention(I know nothing about C++ and I have only code that Dann Corbit sent me to help me when the code is not new varaibles or new functions but only converting the old code that I used to class). In my case suppose that the time control is 40 moves/120 minutes+20 moves/60 minutes+30 minutes/rest of the game. I have num_moves_1=40 num_moves_2=20 num_moves_3=Infinit(defined to be 9999) I get all this varaibles based on the numbers that I get after the level command Is it logical to use them as attributes when the function of the level command is a member function? Is it logical to use the number of moves to the next time control also as attribute that is calculated from other attributes by a member function? > >Don´t use attributes as parameters to members as they have direct access to >those attributes. This works very well if classes don´t get too large. > >To get "perfect": >If ever you access an attribute use "getter" and "setter". A getter is a member >that gets the value of an attribute, the setter sets it´s value. I use this >method in larger classes only. > >Greetings Volker This was exactly my idea to use getters so the member function that calculate the number of moves for the next time control can practically get attributes as parameters but I also thought that I do not need parameters like you suggest. I still thought that maybe it is better to use them because I saw that other chess programs have a lot of varaibles in their functions so I thought it may be bad programming not to mention the varaibles that the function is using even if they are attributes. Uri
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.