CodeBetter.Com
CodeBetter.Com
RSS 2.0 via Feedburner
           Do you Twitter? Follow us @CodeBetter

Jeremy D. Miller -- The Shade Tree Developer

Under the hood and working with .Net, TDD, Software Design, and Agile Stuff

I'm feeling a little bit old

I've never felt like one of the hoary old veteran developers that prattle on about coding on some sort of hardware I've never even heard of.  I do feel a little bit old today though.  I just saw a post explaining Hungarian notation written for .Net and Java developers that have never seen it -- just in case they ever have to work with a legacy codebase.  Granted, it's been awhile since I've used Hungarian notation personally, but come on!  I'm not that old!  That was *the* way to name variables just a little bit ago!

I do still use underscores to denote a class field, but that's it.  I know that offends some people, but we all have our individual oddities.  I can't say that I miss seeing p_strVariable and m_objInstanceOfAClass in my code though.   



Comments

Chad Myers said:

That reminds me of one of the funniest programming web sites I know: <a href="mindprod.com/.../unmainnaming.html">'How to Write Unmaintainable Code'</a>

Specifically, the 'Naming' section:

"Hungarian Notation is the tactical nuclear weapon of source code obfuscation techniques; use it! Due to the sheer volume of source code contaminated by this idiom nothing can kill a maintenance engineer faster than a well planned Hungarian Notation attack. The following tips will help you corrupt the original intent of Hungarian Notation:..."

# January 26, 2008 9:09 PM

Michael C. Neel said:

I've adapted my Hungarian to a more modern .Net dialect.  I normally name controls in a Hungarian style, so a textbox might be tbFirstName, ddlState would be a DropDownList, bSave would be a button.  Given the code behind of ASP.NET and WPF it really helps when trying to remember the control's name/id in code.  I do find my self doing sbResult for StringBuilder as well ;)

# January 26, 2008 10:17 PM

Lamar said:

How do you guys name your controls in WinForms and asp.net?  That area seems like one of the few place in .Net that some people still use Hungarian notation.  Is anyone NOT using hungarian for controls?

# January 26, 2008 10:30 PM

Marlun said:

I name my winform controls like nameTextBox, ageTextBox, etc. It feels good to me.

# January 27, 2008 4:50 AM

mkuczara said:

Seems Hungarian notation is alive and kicking. we use slighlty transformed H Notation in our  projects -

ddl for dropd won lists, bt for buttons, etc. It really helps in such ugly functions like .FindControl("ctrlName");

# January 27, 2008 5:35 AM

Florian Krüsch said:

variable - is that how you call registers nowadays?

# January 27, 2008 6:00 AM

Markk said:

I still work with a group of colleagues that programmed in vb6 for years. Thus, even in our current .Net project, they still want to put everything inside forms, and still use hungarian notation.

It makes me weep!!

Other weird stuff I see regularly:

- Functions that dont return anything.

- Objects everywhere for no reason, instead of strings or integers

# January 27, 2008 7:26 AM

Jeremy D. Miller said:

@Lamar,

I ditched Hungarian notation for controls quite a while ago under the influence of another developer.  I name things either:

stateComboBox, cityTextbox or just stateField, cityField (habit I picked up from another dev)

Dropping hungarian notation for your controls makes them easier to find in Intellisense.  For the first choice, ReSharper's suggest naming functionality helps quite a bit.

# January 27, 2008 7:36 AM

Brian Sullivan said:

If it makes you feel any better, I'm only 3 years out of school, and we used Hungarian notation when studying Win32 development.  We did that before we got to do any .NET programming.

# January 27, 2008 10:31 AM

Ian Cooper said:

Well I'm older than you but do remember the hideous days of doing Win32 programming when prefixes like lpsz were not uncommon (long pointer to null-terminated string in case you all cared).

However, I still see it in dynamic languages (frx javascript), where folks often try to indicate the type of a parameter to a method by using Hungarian notation. Its an interesting one because it suggests that folks find some indication of type helpful, which is often lacking from the context when browsing code written wtih dynamic languages.

# January 27, 2008 11:25 AM

Ian Cooper said:

As an additional thought. Do the youngsters know what a long pointer was as opposed to a short one :-)

# January 27, 2008 6:00 PM

Paul Hatcher said:

A long pointer was one that took slightly longer to become corrupted than a short pointer :-)

# January 28, 2008 6:42 AM

Peter Ritchie said:

It would have been nice if we had never needed to see Hungarian notation.  If it makes you feel better, I remember a time before Hungarian notation....

# January 28, 2008 9:16 AM

The Other Steve said:

Back in my day we used descriptive variable names like i1, i2, i3, ab1, ab2, ab3...  And we liked it!  None of this weird Hungarian or Camel casing to make the code unreadable.

# January 28, 2008 9:44 AM

Jeremy D. Miller said:

@The Other Steve,

Okay Dana Carvey.  I remember doing i1, i2, i3, etc. in my Fortran 77 code in college.  I remember it taking an hour a piece to debug 50 lines of code.

# January 28, 2008 9:50 AM

Tom Opgenorth said:

I remember good old Basic on the Apple ][+, where only the first two characters of a variable name were used.  Fun stuff.

@Ian I suppose that you remember "thunking" too?  Fun stuff.

Of course, there are still some tendrils of Hungarian Notation still floating around that don't seem to want to die:  A lot of developers still preface their interfaces with "I", as in IAuthenticationService.  

# January 28, 2008 12:36 PM

Paul Hatcher said:

The weirdest one I remember was looking at some RPG once, it was fixed column layout which meant one word could run into another on occassion, yech!

I think the IAuthenticationService still makes sense 'cos then the concrete implementation is AuthenticationService, otherwise you have to think up yet another name, don't like just separating the names by a namespace.

# January 28, 2008 12:48 PM

The Other Steve said:

Ok, in all seriousness.  I do tend to use hungarian notation on UI bits, like txtAddress, or ddlState, etc.  I use I to preface interfaces, as Paul Hatcher pointed out.

Where I have the most trouble is in local variables inside methods.  What do I call my StreamReader?  sr, myReader, objReader?  It's not as though I really care about the name as it's just used in say two lines... one to open, and the other to read from it.

# January 28, 2008 1:27 PM

Jason Short said:

I admit that I still use hungarian like notion on some things, especially ASP.NET pages.  txtSOMETHING.Text may seem redundant to some, but makes sense to me that all my text boxes are sorted together with intellisense.

And yes I do remember thunking as well (Ahh, Win32s still gives me nightmares).  Good read, and yes now I feel old too...

# January 30, 2008 2:53 PM

David Carrillo said:

Hungarian notation and Camel are good for clean code for me. That for controls on .NET where the objects inherit properties and you can't know if the ..Text is for a TextBox, ComboBox or any other control for example

# February 18, 2008 11:12 AM

Leave a Comment

(required)  
(optional)
(required)  

Enter the numbers above:
Add

About Jeremy D. Miller

Jeremy began his IT career writing "Shadow IT" applications to automate his engineering documentation, then wandered into software development because it looked like more fun. Jeremy previously worked as a systems architect building mission critical supply chain software for a Fortune 100 company and learned agile development practices as a .Net consultant at ThoughtWorks, one of the pioneers of agile development. Jeremy is the author of the open source StructureMap (http://structuremap.sourceforge.net) tool for Dependency Injection with .Net and the forthcoming StoryTeller (http://storyteller.tigris.org) tool for supercharged FIT testing in .Net. Jeremy's thoughts on just about everything software related can be found on his weblog "The Shade Tree Developer" at http://codebetter.com/blogs/jeremy.miller, part of the popular CodeBetter site. Jeremy is a Microsoft MVP for C#. Check out Devlicio.us!

Our Sponsors

Free Tech Publications

This Blog

Syndication

News

All opinions expressed here constitute my (Jeremy D. Miller's) personal opinion, and do not necessarily represent the opinion of any other organization or person, including (but not limited to) my fellow employees, my employer, its clients or their agents.

About Me

"Best Of" Compendium

StructureMap (Dependency Injection for .Net)

StoryTeller (Supercharged Fit)

Build your own Cab

TestDriven

MVP