Sunday 24 March 2013

Hungarian Notation (revisited)

Ages ago (in the context of the lifetime of this blog, anyhow... Aug last year)  I wrote an article on my thoughts regarding Hungarian Notation. This fell back on my radar as someone has just posted a comment against that article.

Just quickly, since writing that article I have discontinued H/N for any of my code other than when constrained by my employer's coding standard. So for all the code for this blog, and all the code for side projects I do (not many, and they're not making much progress) I no-longer use hungarian notation ever. And I think my code is much better for it. I need to take slightly more time over my variable-naming sometimes, and sometimes the variable names get a bit longer, but on the whole my code is much clearer I think, both in the sense of how understandable it is, as well as how aesthetically pleasing it is on the screen (OK, both of those are quite subjective).

Anyway, other than when I need to, I have shelved the idea of using it. Which I think is good.

What's interesting about this is that now my impulse is to not use it, and I find myself resisting it in my code at work too... my hungarian notation "muscle memory" has completely switched now. Fortunately I catch myself before submitting my work for code review, so I don't get my hand slapped.

I'd try to change the coding standard at work (it is outside my remit, so I can only suggest things), but I think with hundreds-of-thousands of lines of code all uniformly (-ish) using it, it would be a backwards step to suddenly stop. I'm still mulling over a viable approach to discontinuing it in a way that doesn't result in making the code messier and less uniform by having a mishmash of both styles. That would help no-one.

It's good to keep learning and growing in this line of work. Even if it's just in an area as mundane as variable-naming.