I think there are plenty of times when it's unambiguous what things
mean. If I've got an int variable "activeThreads" then that's clearly
the number of active threads (in whatever context) without me having to
elaborate in the variable name.
It's not clear to me. What kind of thread is that that you are counting?
When you include the word "Threads" in your variable name, does that mean
a .NET Thread class instance? Does it mean a worker thread from the
thread pool? Does it mean a native Win32 thread? Is it a thread handle,
or a thread ID? Or a .NET reference?
It's ambiguous. Using Hungarian, you would have a specific type tag
assigned to a specific data structure name, with a unique association.
That's part of the rules of Hungarian. Without Hungarian, I have no idea
whether you are using the word "Thread" to uniquely describe a specific
reference to a thread, or if different variables all of which have the
name "Thread" in it could be referring to different kinds of data.
If you attribute that correctness to Hungarian, to what do you
attribute the fact that I *haven't* mismatched strings and other types
often, while not using Hungarian?
I make no attribution. How could I? I have no experience with your code,
or your development style. It would be foolish of me to assert anything
one way or the other about how YOU code.
[...] Every piece of software I've ever used
has bugs in it, and I would be willing to bet that at least one of the
bugs in each of those programs involves a mis-match of semantic type.
I think that's a bold claim
That's your prerogative. I obviously don't. To me, it's a matter of
statistics. There are so many bugs in each piece of software, the chances
that such a bug does not exist seems extremely low to me. Certainly worth
betting on.
- of course, we'll never know. On the other
hand, you're more than welcome to look at my MiscUtil library, find
bugs (of which I'm sure there are plenty) and spot which ones would
have been solved by using Hungarian notation.
http://pobox.com/~skeet/csharp/miscutil
Unless you're paying me, and well, that's a waste of my time.
The project I'm on at work is now nearing completion, and we've been
concentrating on fixing bugs. Guess how many have been due to type
mismatches...
I don't know. How many bugs have you documented throughout the entire
development cycle?
By not allowing exceptions, you end up with less readable code (IMO,
and clearly in the opinion of others) which allows other kinds of bugs..
Such as? What sorts of bugs do you assert Hungarian creates?
Can you give me any reason to change my habits given that I can't
remember running into a bug along the lines you describe other than in
situations where I've already changed my habits now?
Sure. Hungarian isn't just about preventing that sort of bug. But you
would have to actually read about Hungarian to learn that. Frankly, I
don't feel that my role here is to evangalize Hungarian. It's no big deal
to me if people choose not to use it. I'm not going to redocument
everything about Hungarian here, when people who are actually interested
could just use Google and learn about it for themselves.
That said, if you are really interested, you might read what's on these
web pages:
http://www.idleloop.com/hungarian/index.html
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs600/html/hunganotat.asp
You can even read Simonyi's original thesis here (it's a Postscript file,
so you'll need something that can display or print Postscript):
http://www.parc.xerox.com/about/history/publications/bw-ps/csl76-7.ps
Keeping in mind, of course, that many of the suggested type tags are
indeed outdated in the .NET context, but that doesn't invalidate the
usefulness of Hungarian. It simply means one needs to adapt to concept to
..NET with new, more appropriate tags. More importantly, much of the rest
of the notation can be used unchanged; prefixes and suffixes in particular
still apply just as well as they always have.
LOL - I didn't actually even notice it was my own post. Deep apologies
on that front. And no, I didn't expect you to have read that thread - I
just don't expect to be patronised.
I'm sorry if you feel patronized. I have only pointed out where you and
others have made incorrect statements about Hungarian. I can only make
assessments of your knowledge of Hungarian based on what you actually
write here, and for the most part what has been written here displays
ignorance of Hungarian.
I reiterate: if you are not ignorant of Hungarian, I recommend you refrain
from writing incorrect things about it. If anything, it is more of a
blemish on your reputation to claim knowledge and then write falsehoods,
than to simply not have the knowledge in the first place.
Claiming I haven't the "fainted clue" about what Hungarian notation is
about is completely incorrect, as well as extremely patronising.
I made no such claim. I simply pointed out that what's been written here
against Hungarian appears to be written by people without the faintest
clue. There's a difference, and it has to do with the line between whatI
can truly know about what you and others know (which is very little,
frankly) and what impression *you* give of what you know.
[...]
My reasons are:
1) The perceived disadvantages of *not* using Hungarian haven't hit me
This is the only valid reason of the two, and frankly that's something you
need to deal with on your own. I don't see it as my role to convince you
to use Hungarian.
2) I strongly believe that Hungarian *is* less readable without
training oneself to do it.
Practically everything about programming is "less readable" without
training oneself to do it. The requirement of training and practice in no
way argues against use.
Suppose I suggested writing all variable names backwards. I dare say
people could train themselves to read backwards at speed, but until
presented with a good reason to do so, it would be foolish to think it
a good idea.
Of course it would. It would be foolish to think anything a good idea if
it didn't provide some benefit. Duh.
Rather than me presenting you with reasons to reject Hungarian, isn't
the onus on you to present reasons which make sense to me (i.e. fixing
the type of bug which I *have* experienced) to move from a system which
is more easily readable to a less readable one?
No. I have no onus to convince you at all.
Let me see if I can make this plain, since you don't seem to get it yet:
My contribution here is not intended to sway people to the side of
Hungarian. I couldn't care less who uses Hungarian, and whether people
like it or not.
Rather, my point is simply that the only arguments presented here against
Hungarian have been based solely on an incorrect understanding of
Hungarian. Why bother to argue against something if you aren't going to
bother to get the facts right?
I would have the same objection if someone argued against using VB .NET by
claiming that the .NET Framework runs slower with code written in VB .NET,
or if someone argued against driving to France from England via the
"chunnel" by claiming that your tires would melt because you get too close
to the core of the Earth. It's not that I really care how someone decides
these patently subjective issues, it's just that I feel strongly that any
such decision should be based on correct information.
The proof should be in the pudding. If this were a serious issue (which
I believe simple readability to be) then I should be seeing significant
numbers of bugs due to type mismatches. I can't remember *any* beyond
units, which I've already conceded. Do you put that down to luck, a bad
memory, or miraculously being a brilliant engineer? (For the record,
I'm certainly not claiming the latter.)
I don't "put it down" to anything. That's not my place to do.
The fact remains that when using Hungarian, I code faster, more correctly,
and find that my code remains more consistent over time than using other
naming conventions. The proof IS in the pudding, for me. It's my opinion
that someone who rejects Hungarian ought to at least learn it and try it
for some period of time before deciding it's awful.
That said, I grant that the entire world is filled with people who
prejudge. Even just looking at the computer world, it is filled with
people who prejudge. They argue in favor of their favorite software,
their favorite hardware, their favorite coding standards, their favorite
data structures, their favorite file formats, mostly based on invalid
information.
Frankly, I probably wouldn't have even written anything here except for
the fact that the claims about Hungarian have been so obviously wrong that
it's fairly easy to pick holes in them. I quickly tire of what
essentially amount to religious arguments, and most of the time stay out
of them altogether. I guess I'm just frustrated to see the same old
anti-Hungarian falsehoods showing up here over and over again.
So mark me down as "can't help myself", but at least for now I think I've
written all that I feel motivated to write about Hungarian. Open-minded
people who have been reading this will take the initiative to actually
learn about Hungarian, to try it for some time, see how it helps them when
they've really learned it. Others won't. Either way, it's no skin off my
nose.
Pete