quote:
Principal Two: Encapsulation
This is my primary argument against hungarian notation (which is the ONLY popular style I have a problem with). My contintion (for which I have run no experiments to prove) is that it is NOT a good idea to display type information in the code, as this is COMPLETELY CONTRARY TO OBJECT ORIENTED PROGRAMMING. The idea of object oriented programming is encapsulation and data hiding, the fundamental idea is ABSTRACTION (omiting of certain detials in order to see the wholistic structure better). The whole point of polymorphism is so that different derived classes may be treated the same, the whole point of classes is so that implementation details may be ignored, and FOR ME, the whole point of naming conventions is so that THE INTENDED USE of a variable / function / or class can be made clear. The header file and code itself will tell you what class an object is and the details of its use (in modern editors this pops up as TOOL TIPS, and there are also dozens of automated tools to generate this kind of documentation) so as a programmer, the only way you can add value is to use names that provide ADDITIONAL / DIFFERENT information than what the language syntax implies.
I don't understand this. You use hungarian notation on the variables HIDDEN in the class. Escapulation is not broken. The people using the class won't see the hungarian notation (except for parameters in public functions, which they'll NEED to know the types of anyways).
I can't begin to explain how important hungarian notation is when working on someone else's code on a large project. It's too easy to be in the middle of someone else's function, and see a variable called "minutes" and have NO clue if that is a string, int, byte, unsigned int, long, etc. If you want to find out you have to look to see if it's a local variable, or a class member, or a global, because you just don't know. Yes, if you DO use one of the editors that keeps track of that stuff (and not everyone does) then you can go through the minimal effort of recompiling to support that feature, and have the program take you to the spot where it is defined. Of course, this does you no good if you are looking at a hardcopy.
Working on your own code, it's hard to see the benifit (and sometimes there ISN'T any) of hungarian notation, but when you are trying to understand someone elses code it will save you lots of time.
Edited by - Houdini on September 13, 2000 2:40:59 PM