On 05-25-97 Thomas Maeder wrote to Benjamin L Mcgee...
BLM> ...I'd appreciate it if you guys and gals would check my work.
TM> ...if somebody shows me his/her (and sometimes even my :-))
TM> C++ code, I always have some remarks.
I'm glad you do, that's why I posted my code.
TM> Don't use #define for anything else than conditional
TM> compiling...
TM> Better write
TM> const unsigned int WHEEL_MAX = 13;
TM> const unsigned int STARTING_CASH = 300;
I agree, clearly a better way.
I once had a guy tell me that constants are a waste of code space. I
still think they are very useful, without regard to the language you
happen to be using. Knowing the best way to define constants is
altogether a different thing. :)
BLM> class Wheel {
BLM> int top;
BLM> int mid;
BLM> int bot;
TM> Instead of exposing member variables in the public interface,
TM> better use accessor methods...
TM> class Wheel
TM> {
TM> public:
TM> unsigned int top() const // accessor methods
TM> {
TM> return myTop;
TM> }
...
I thought there must be some way to do this but wasn't quite sure how.
I hated having those variables waving in the wind, but didn't know
of any other way to do it.
TM> 2) Try to avoid redundant member variables. Instances of class Wheel
TM> each describe the state of a wheel. For this purpose, knowing the
TM> (say) top symbol and the order of the symbols is more appropriate than
TM> your three variables:
Great! I understand that as well. Thank you for all your help.
TM> ú [ Continued In Next Message... ]
Never did get the second half of this message. :)
thanx
*Yes-men: Fellows who hang around the man nobody noes.
e-mail: benjamin.l.mcgee@purgatorie.org
NET-MAIL: Benjamin L McGee on 1:15/7
--- FLAME v1.1
---------------
* Origin: Purgatoire BBS, 719-846-0140, Trinidad, CO, V.34 (1:15/7)
|