S
Serve La
I would like to start a discussion on hungary notation. What are pros, what
are cons? Best use them or not?
are cons? Best use them or not?
Serve La said:I would like to start a discussion on hungary notation. What are pros,
what are cons? Best use them or not?
Richard Heathfield said:Serve La said:
Hungarian Notation can mean at least two different things - a fairly
sensible naming convention, or a mindless prefixing of types to
identifiers (which means you have to go back and change all instances
of an identifier usage if its type changes, or else make an even
bigger mockery of the whole thing).
Which of those would you like to discuss?
The mindless type prefixing yes. I was under the impression that the
hungarian type prefixing was seen as pretty useless nowadays but at work
people want to introduce a coding guideline that forces us to use hungarian.
I pointed them to joel´s article already but it didnt convince them. Are
there actual advantages to using hungarian?
Richard Harter said:Type hungarian is problematic. I suppose it
saves looking up declarations and from time to time it may alert
the reader that something funny is going on.
Richard Harter said:Er, yes, I believe most of us know that. The point of my heavy
handed irony was that the notion of using a naming convention to
indicate types is an ancient one that has been tried and
abandoned more than once.
What I consider important is what the variable relates to. Is it a number of
pixels on your Facebook wall? Is it the change in number of millimeters
between Earth and moon per year? Is it the number of nanoseconds since the
Bolshevik Revolution? Basic names give the context.
"Richard Harter" <[email protected]> schreef in berichtnews:[email protected]...
Yeah thats an advantage, but the type is almost never important when reading
code. I dont need the type get thrown in my face every single time
Personally speaking, I abandoned it because it was a failure.
I suppose everyone has their own definition of failure. My
impression is that it was abandoned because it got in the way of
using meaningful names. However the real gotcha is that
inadvertently failing to declare a variable was not an error - as
a result you got the predefined type instead of what you
intended. Hungarian notation has the opposite problem - there is
nothing in the language to ensure that the type in the name
matches the type in the declaration.
OneThingIHateALotIsVariableNamesThatAreCapitalizedAndJammedTogether. I find
those to be among the hardest to read, completely undoing any other advantages
they may have by other aspects such as type prefixes.
REH said:That's called "camel hump." I alternate between loving and hating it
(currently set to hating).
The usual term is "camel case" or "CamelCase". A more common version
uses lower case for the first letter: "camelCase".
CamelCase for types(ie. class), and camelCase for variables, seems to
be very popular.
mic
Nick Keighley said:smart pointers are no picnic, as are virtually all
automatic devices with something like "smart",
"simple" or "fast" in their name.
(C++ Frequently Questioned Answers (FQA))
cf. SMTP, SNMP
Phil Carmody said:Compare 'Democratic' in country names.
Ditto 'premium' in beer names.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.