<Rant topic='Hungarian'>Damn I get mad about stuff!
Some things get me really fired up. Not your typical high school debating issues (abortion, euthenasia, religion, ho hum?) -- but Hungarian naming standards. Now that's a fiercesome topic! Full of emotion! A political minefield! Oh I've tried to code without Hungarian. I've followed the new standards. But it's a crock! A marketing foible! Getting rid of Hungarian is just a terrible piece of 'Fashion' that will later be looked back on with regret. 'Well we've got .Net now, so we'd better make all of our code look minimalist, clean and non-technical...' 'Everything's an object, you know, like Java, so let's do what sun does' [Rant continues, with comparisons...]
You may feel that for an API (a public API that you are going to foist onto other people) will *look* better if you avoid hungarian. That's kind of true.
But in such a case the details of your API are largely a marketing exercise and have little to do with 'Maintainability.'
But for real code, the guts of your code, the sort of code you write every day and work with every day, nothing can beat Hungarian.
Arguments I've seen against Hungarian
- "Hungarian makes code harder to read. for example: m_dblPrice vs Price."
No, it isn't harder to read, it's more informative and easier to understand.
"Price" alone tells you much much less than "m_dblPrice".
The reader's digest condensed version of "Slaughterhouse 5" is a quicker read too. But that doesn't make it better.
To a seasoned developer, "m_dblPrice" is easier to read than just "Price". Your mind is not distracted by questions like, "hang on, is this the pricing object? or the price parameter? or the local static price variable? or the module level... let me just hover over it, or right click on it and then... oh!" You get the idea.
- "With Intellisense you can find out the type and scope of a variable more easily than previously."
Not as easily as you can with Hungarian, baby!
You can only find out one variable at a time
Without Hungarian, you have to actively seek that information out.
Intellisense doesn't help if the code is printed out, or pasted into an email, or provided on a web page, or being viewed in any other way. (You probably read a lot of code outside of the IDE, just like I do.)
- "It takes longer to write "m_dblPrice" than it does to write 'Price'"
Yes but it's quicker to use and maintain, because you can find it faster.
Roland Weigelt has excellent pictures that demonstrate this.
- "In Hungarian, if you change the type of the variable then you have to change the name. What a mess!"
This is a very good point, and I concede it utterly.
However, in Whidbey, refactoring support promises to be a lot better.
You will be able to rename a variable with ease.
- In Hungarian, if someone puts in the wrong prefix, it will mislead you.
True enough. But FX-Cop can gobble up problems of this sort. You needn't lose any sleep over it.
The main reason I've seen for ditching hungarian is:
"But this is the new way."
Come here and say that! I dare you! You'll feel the stinging wrath of my sarcastic wit! You will be sorry, dunderhead.
</Rant>
Add or view comments about this page
|
Articles
Do they store the code for TFS in TFS?
Sudden TimeSnapper Discount!
How Can Microsoft Beat Google?
TimeSnapper 3.1: Attack of the the Red/Green Stripes
21 tools used in our MicroISV
Lost Treasures of the DOS World: tree!
The Virtual Machine Machine and the Virtual Virtual Machine
Should Linq To Sql Go "Open Source"?
Redux: New Synchronisation Idea Overlooked By Microsoft
New Synchronisation Idea Overlooked By Microsoft Live team
Visual Studio UX Taskforce, Office UX Taskforce... etc.
How to be Jeff Atwood
.: secretGeek :: Complete Archives :.
25 steps for building a Micro-ISV
3 Minute Guide Series
Top 10 SecretGeek articles
Downloads
TimeSnapper.com
Version 3.1: instant productivity profiles
ShinyPower Now at CodePlex
NextAction Managing the top of your mind
Thai Erawan, Brisbane Restaurant
World's Simplest Code Generator
Gradient Maker
How to be depressed
You are not inadequate.
Recommended Reading
The Best Software Writing I
The Business Of Software (Eric Sink)
Recommended blogs
Jeff Atwood
Reginald Braithwaite
Joseph Cooney
Phil Haack
Scott Hanselman
Julia Lerman
Joel Pobar
Eric Sink
Joel Spolsky
Des Traynor
Aggregated Links
programming.reddit.com
dzone
dot net kicks
Human Link Machines
interesting finds
a continuous learner's weblog
arjan's world
n links today
new and notable
morning coffee
learning .net
weekly link post
(my del.icio.us account)
|
|
|