Jeremy D. Miller -- The Shade Tree Developer

Sponsors

The Lounge

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
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.   


Posted 01-26-2008 6:51 PM by Jeremy D. Miller

[Advertisement]

Comments

Chad Myers wrote re: I'm feeling a little bit old
on 01-26-2008 9:09 PM

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:..."

Michael C. Neel wrote re: I'm feeling a little bit old
on 01-26-2008 10:17 PM

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 ;)

Lamar wrote re: I'm feeling a little bit old
on 01-26-2008 10:30 PM

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?

Marlun wrote re: I'm feeling a little bit old
on 01-27-2008 4:50 AM

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

mkuczara wrote re: I'm feeling a little bit old
on 01-27-2008 5:35 AM

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");

Florian Krüsch wrote re: I'm feeling a little bit old
on 01-27-2008 6:00 AM

variable - is that how you call registers nowadays?

Markk wrote re: I'm feeling a little bit old
on 01-27-2008 7:26 AM

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

Jeremy D. Miller wrote re: I'm feeling a little bit old
on 01-27-2008 7:36 AM

@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.

Brian Sullivan wrote re: I'm feeling a little bit old
on 01-27-2008 10:31 AM

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.

Ian Cooper wrote re: I'm feeling a little bit old
on 01-27-2008 11:25 AM

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.

Ian Cooper wrote re: I'm feeling a little bit old
on 01-27-2008 6:00 PM

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

Paul Hatcher wrote re: I'm feeling a little bit old
on 01-28-2008 6:42 AM

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

Peter Ritchie wrote re: I'm feeling a little bit old
on 01-28-2008 9:16 AM

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....

The Other Steve wrote re: I'm feeling a little bit old
on 01-28-2008 9:44 AM

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.

Jeremy D. Miller wrote re: I'm feeling a little bit old
on 01-28-2008 9:50 AM

@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.

Tom Opgenorth wrote re: I'm feeling a little bit old
on 01-28-2008 12:36 PM

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.  

Paul Hatcher wrote re: I'm feeling a little bit old
on 01-28-2008 12:48 PM

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.

The Other Steve wrote re: I'm feeling a little bit old
on 01-28-2008 1:27 PM

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.

Jason Short wrote re: I'm feeling a little bit old
on 01-30-2008 2:53 PM

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...

David Carrillo wrote re: I'm feeling a little bit old
on 02-18-2008 11:12 AM

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

Add a Comment

(required)  
(optional)
(required)  
Remember Me?