Monday, March 26, 2012

Why NOT hungarian notation?

I just discovered that MS recommends that we NOT use hungarian notation with
the .net framework:
http://msdn2.microsoft.com/en-us/library/ms229045.aspx
What are the real cons for using it?
I tend to use it a lot, especially when IDing my controls. For instance the
controls in a contact form I create could be IDed as such:
tbx_firstName
tbx_emailAddress
ddl_state
I find this really helpful when in codebehind.
is the 'no hungarian' merely a preference MS has, or are there specific cons
to me being stubborn and sticking with it?
-Darrel
========================================
=========================
Win prizes searching google:
http://www.blingo.com/friends?ref=h...FnTqhv-2GE1FNtA"darrel" <notreal@.nowhere.com> wrote in message
news:eVFt$muGHHA.2456@.TK2MSFTNGP06.phx.gbl...

>I just discovered that MS recommends that we NOT use hungarian notation
>with the .net framework:
> http://msdn2.microsoft.com/en-us/library/ms229045.aspx
Weird, isn't it! It was all the rage for years, then suddenly they don't
like it any more...

> What are the real cons for using it?
None whatever.

> I tend to use it a lot, especially when IDing my controls.
Me too - all the time.

> I find this really helpful when in codebehind.
Likewise.

> is the 'no hungarian' merely a preference MS has,
I have no idea...

> or are there specific cons to me being stubborn and sticking with it?
None whatever.
>> or are there specific cons to me being stubborn and sticking with it?
> None whatever.
Ha! Thanks for the feedback, Mark. At least I can find peace with me knowing
that I'm not alone in wanting to stick with it. ;o)
-Darrel
The biggest argument against hungarian notation is that it makes it harder
to refactor code. People argue that it's violates the Don't Repeat Yourself
(DRY) principle. Personally, I think that's a little much, but the side
effect IS the same. If you change the type of your variable, you now need to
change all instances of that variable.
if you have rptBooks and want to change it to a datagrid, you now have to
refactor your name or risk having hard code to maintain.
With the advances in IDEs generally and intellisense specifically, the
question is what value does hungarian notation offer?
I'd be interested in taking a look at a codebehind page you feel it ads
value.
Karl
http://www.openmymind.net/
http://www.fuelindustries.com/
"Mark Rae" <mark@.markNOSPAMrae.com> wrote in message
news:%23G5m8uuGHHA.1252@.TK2MSFTNGP02.phx.gbl...
> "darrel" <notreal@.nowhere.com> wrote in message
> news:eVFt$muGHHA.2456@.TK2MSFTNGP06.phx.gbl...
>
> Weird, isn't it! It was all the rage for years, then suddenly they don't
> like it any more...
>
> None whatever.
>
> Me too - all the time.
>
> Likewise.
>
> I have no idea...
>
> None whatever.
>
"darrel" <notreal@.nowhere.com> wrote in message
news:eCtm4DvGHHA.420@.TK2MSFTNGP06.phx.gbl...

> Ha! Thanks for the feedback, Mark. At least I can find peace with me
> knowing that I'm not alone in wanting to stick with it. ;o)
Without doubt the stupidest reason for not using it I've ever come across
was that you might change the underlying datatype (e.g. from byte to
integer) that a variable referred to, so you'd have to go through your
entire code and change it...
Well, my copy of VS.NET has got a find and replace utility...
"Karl Seguin" <karlremove@.removeopenmymindremovemetoo.andmenet> wrote in
message news:%23s3IdGvGHHA.420@.TK2MSFTNGP06.phx.gbl...

> If you change the type of your variable, you now need to change all
> instances of that variable.
Personally, I would use Find / Replace for such a task - wouldn't you...?
On Fri, 8 Dec 2006 10:55:56 -0600, "darrel" <notreal@.nowhere.com>
wrote:

>I just discovered that MS recommends that we NOT use hungarian notation wit
h
>the .net framework:
>http://msdn2.microsoft.com/en-us/library/ms229045.aspx
>What are the real cons for using it?
>
Nothing although the various 'dialects' can be confusing and
internally inconsistent.

>I tend to use it a lot, especially when IDing my controls. For instance the
>controls in a contact form I create could be IDed as such:
>tbx_firstName
>tbx_emailAddress
>ddl_state
>I find this really helpful when in codebehind.
>
My preference is to be verbose as needed to make the code easier to
read. A few extra key strokes for clarity can go a long a way i.e.
firstNameTextBox or firstNameEdit.

>is the 'no hungarian' merely a preference MS has, or are there specific con
s
>to me being stubborn and sticking with it?
>
You may run into situations where corporate/department/office policy
does not appreciate hungarian notation as much as you do. For all
practical purposes IntelliSense and similar tools make hungarian
notation obsolete.
regards
A.G.
Darrel,
for a very interesting article on the issues and history, read :
http://www.joelonsoftware.com/articles/Wrong.html
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espaol : http://asp.net.do/foros/
===================================
"darrel" <notreal@.nowhere.com> wrote in message news:eVFt$muGHHA.2456@.TK2MSFTNGP06.phx.gbl.
.
>I just discovered that MS recommends that we NOT use hungarian notation wit
h the .net framework:
> http://msdn2.microsoft.com/en-us/library/ms229045.aspx
> What are the real cons for using it?
> I tend to use it a lot, especially when IDing my controls. For instance th
e controls in a contact
> form I create could be IDed as such:
> tbx_firstName
> tbx_emailAddress
> ddl_state
> I find this really helpful when in codebehind.
> is the 'no hungarian' merely a preference MS has, or are there specific co
ns to me being stubborn
> and sticking with it?
> -Darrel
> --
> ========================================
=========================
> Win prizes searching google:
> http://www.blingo.com/friends?ref=h...FnTqhv-2GE1FNtA
>
no.
find/replacing is dangerous. What happens if you use that same name
somewhere else but don't change its type?
I use JetBrains Resharper which provides much better refactoring than VS.NET
2005. It would do it for me. So that's a case against my own argument :)
Karl
http://www.openmymind.net/
http://www.fuelindustries.com/
"Mark Rae" <mark@.markNOSPAMrae.com> wrote in message
news:%23%23NtiJvGHHA.3952@.TK2MSFTNGP02.phx.gbl...
> "Karl Seguin" <karlremove@.removeopenmymindremovemetoo.andmenet> wrote in
> message news:%23s3IdGvGHHA.420@.TK2MSFTNGP06.phx.gbl...
>
> Personally, I would use Find / Replace for such a task - wouldn't you...?
>
I hope you don't use "obj" or "o" ...
http://www.openmymind.net/
http://www.fuelindustries.com/
"darrel" <notreal@.nowhere.com> wrote in message
news:eVFt$muGHHA.2456@.TK2MSFTNGP06.phx.gbl...
>I just discovered that MS recommends that we NOT use hungarian notation
>with the .net framework:
> http://msdn2.microsoft.com/en-us/library/ms229045.aspx
> What are the real cons for using it?
> I tend to use it a lot, especially when IDing my controls. For instance
> the controls in a contact form I create could be IDed as such:
> tbx_firstName
> tbx_emailAddress
> ddl_state
> I find this really helpful when in codebehind.
> is the 'no hungarian' merely a preference MS has, or are there specific
> cons to me being stubborn and sticking with it?
> -Darrel
> --
> ========================================
=========================
> Win prizes searching google:
> http://www.blingo.com/friends?ref=h...FnTqhv-2GE1FNtA
>

0 comments:

Post a Comment