quote:
Original post by Zeblar Nagrim
Some C++ guys use only class members and declare most of them private and think they code in a super object-orientated way. I think that is ridiculous and slow down your tempo. Let say u have a int variabel called x in a class. Why should I make it private and change it with two member functions (commonly called get/set something) instead of declaring it public?
1) You may not want the programmer to be able to set variable x, only retrieve the value.
2) Only allows the user of the class to access the interface of the class, and not the class innards. This keeps your class black boxed (ie, totally seperate) from other code. This way you can change the implementation of the class without creating compile errors in programs that use the class (ie, you can change the variable x to variable y and not have to change code in 100 files that use that variable). The is simple code reusing 101.
3) Detailed variable/function naming and comments also "slow down your tempo", but that doesn't mean they are bad.
4) You can make those get/set functions inline so you get back that 0.0000001 fps you lost by making function accessors.
quote:
Original post by Arkon
well those are called c++ pure programmers
like they derive the CObject class in MFC and stuff
Uh, I sure as heck don't use MFC for game programming. I DO use it for Windows programming but I sure don't think that MFC is an elegant use of object oriented programming. It just happens to be much faster to work with compared to straight Win32, when speed isn't a major concern.
You should really watch those gross generalizations. Doesn't give you much credibility.
quote:
Original post by Arkon
besides you can "hack" the private easily
did it once in VC 
As far as I'm concerned "hack" em if you'd like. Making the variable private isn't supposed to make it impossible for the programmer to get to the variable. You can "hack" local variables in C, so does that mean you should use all global variables?
Making variables private are for reasons I've already stated above. If a programmer wants to get direct access to them that badly, then I say go for it.
quote:
Original post by Arkon
and another thing is that using methods for setting a variable
is just for "beautiy" of the OO part 
Yes, it is.
quote:
Original post by Arkon
hmm besides C++ is actually SLOWER that c
(just if you use the class becuase of the virtual tables etc)
C++ is
NOT slower then C in any way whatsoever! Please try to understand the difference between C++ and object oriented programming, and how/when C++
CAN be slower before you make such ridiculous generaliztions such as this.
First of all, using C++ does not mean you use classes. And using classes does not mean you use virtual functions. And using virtual function does not mean you need to access the virtual table dynamically. It would only need to do so when the instance of a class wasn't allocated on the heap. If it was, then any compiler worth a damn would compile away the vt.
And even when you do use virtual function on the stack and need to access the vt, the speed loss is negligible. Tons of games have been written in C++ using object oriented techniques, Unreal and AOK coming to mind off hand, to prove that point.
- Houdini
Edited by - Houdini on June 4, 2001 10:11:41 AM