473,657 Members | 2,862 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

I finally did it-- hungarian notation

CMM
So after three years of working in .NET and stubbornly holding on to my old
hungarian notation practices--- I resolved to try to rid myself of the
habit. Man, I gotta say that it is liberating!!! I love it.

At first I struggled with how to name controls. I tried to keep some sort of
notation with them... but I threw that away too!!! I now name them as if
they were simply properties of the form (FirstNameLabel , etc.)... which they
ARE!... and when I reference them I use the Me keyword (as all properties of
a class should be referenced). Pure joy!

Alas, I still use "m_" to indicate private class scoped variables. It helps
to set them apart from properties and with avoiding collisions with property
names... because, well, VB is not case sensitive like C#!!! This causes
problems as in the following example:

Private firstName As String
Public Property FirstName() As String
Get
Return firstName
End Get
Set(ByVal value As String)
firstName = value
End Set
End Property

I recommend that any hold outs (you know you're out there!) give it a try.
It's like a big weight is lifted from your shoulders.
Jan 31 '06
66 3681
"Cor Ligthert [MVP]" <no************ @planet.nl> schrieb:
* The first character of a word/sentence serves an important role for
word recognition. In classic typography the first letter has often
been
written in upper-case and sometimes ornamented to underline its
importance. By starting identifiers' names with a lower-case letter
while using upper-case letters inside the identifier this long
tradition
in typography is obeyed.
However this is real something special German speaking people would see.


Not really. Capitalization of initials is common in German, English, and
IIRC French, and likely other languages too.
true. We by instance make in our language from more words one word by
concatenating them (you will often see me that wrong in English doing as
well).


Well, that's common in German too.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 31 '06 #11
"Cor Ligthert [MVP]" <no************ @planet.nl> schrieb
Herfried,

I have forever hated the use of the underscore in any dataname.

Why not just mMyPrivate instead of m_MyPrivate?

private mMember as integer
private mEmber as integer 'oops, is property, too.

public property Ember
'...
end property

public property Member
'...
end property

Doesn't work. ;-) Well, rare case but possible. Avoidable with "_" (if "_"
is not used with property names). I use the underscore for visual clarity
and for better intellisense, but I also see the drawback of "hidden"
underscores for the last declaration if the "procedure separator line" is
active in the editor - but that's only one declaration and not that
important.

I use the prefix "f_". f = Field. Only for those that also have a property.
For other fields I don't use a prefix, just like I do not use "fun_" for
functions or "prop_" for properties. Fields and other members are on the
same level, thus I don't distinguish in the usage of a prefix. But I also
make exceptions, like "txt" for textboxes (or others for controls) which
are also fields.

My 2 Eurocents.
Armin

Jan 31 '06 #12
Herfried,

However this is real something special German speaking people would see.


Not really. Capitalization of initials is common in German, English, and
IIRC French, and likely other languages too.

But not the use of capitals. Just pasted from Bild without any extra meaning
for the text..

Öffentliches Interesse erregt der Patent-Motorwagen mit der
100-Kilometer-Reise von Benz’ Ehefrau Bertha, die 1888 mit dem Wagen von
Mannheim nach Pforzheim fährt. Eine „Promotion-Tour“, die Benz eine Reihe
neuer Kunden verschafft. Eine Erfolgsgeschich te beginnt. Nicht nur für Karl
Benz.

Cor
Jan 31 '06 #13
Thanx. I appreciate the effort.

Ralf
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:uH******** *****@TK2MSFTNG P14.phx.gbl...
: "_AnonCowar d" <ab****@uvwxyz. com> schrieb:
: > : > So after three years of working in .NET and stubbornly holding on to
: > my
: > : > old hungarian notation practices--- I resolved to try to rid myself
of
: > : > the habit. Man, I gotta say that it is liberating!!! I love it.
: > :
: > : Well, I do not use type prefixes ("Systems Hungarian") because I use
: > : 'Option Strict On' most of the time. However, I use type prefixes
when
: > : dealing with late binding (variables typed as 'Object'). Additionally
: > : I use the 'm_' prefix to mark private fields, and I tend to use Apps
: > : Hungarian because it still makes sense in strictly-typed languages.
: > :
: > : On a side note: I still refuse to use camel case for the reasons
listed
: > : in <URL:http://dotnet.mvps.org/dotnet/articles/camelcase/> (German
: > : article!).
: >
: > Could you summarize the points being raised in this article for those of
: > us
: > who don't read German? Thanx,
:
: The points made in the article are:
:
: * Distinction of two identifiers (property, backing field) by case only
: can
: lead to bugs in the implementation which cannot be easily detected.
:
: * By naming the property using pascal case and the backing field using
: camel case it's harder to visually detect that both belong to each
: other.
: This argument is based on a human visual character recognition model.
:
: * The naming rules described in the .NET Framework Design Guidelines
: and the internal Guidelines published by Brad Abrams [MSFT] cannot be
: applied to VB.NET because VB.NET is not case-sensitive.
:
: * The first character of a word/sentence serves an important role for
: word recognition. In classic typography the first letter has often
been
: written in upper-case and sometimes ornamented to underline its
: importance. By starting identifiers' names with a lower-case letter
: while using upper-case letters inside the identifier this long
tradition
: in typography is obeyed.
:
: * Most naming guidelines are made by developers only instead of
: consulting developers, psychologists, linguists, etc. who have the
: scientific background to optimize naming guidelines.
:
: --
: M S Herfried K. Wagner
: M V P <URL:http://dotnet.mvps.org/>
: V B <URL:http://classicvb.org/petition/>
:
Jan 31 '06 #14
Armin,

Where is that underscore situated on your keyboard. I type with ten fingers,
that underscore is so far on my keyboard, maybe is it that why I don't like
it. However it is for me probably the most that I don't like it because, as
something is underlined than it becomes not visible.

Although don't misunderstand me, your explanation makes sense. Probably I
just take another word in those cases.

:-)

Cor

"Armin Zingler" <az*******@free net.de> schreef in bericht
news:uX******** ******@TK2MSFTN GP14.phx.gbl...
"Cor Ligthert [MVP]" <no************ @planet.nl> schrieb
Herfried,

I have forever hated the use of the underscore in any dataname.

Why not just mMyPrivate instead of m_MyPrivate?

private mMember as integer
private mEmber as integer 'oops, is property, too.

public property Ember
'...
end property

public property Member
'...
end property

Doesn't work. ;-) Well, rare case but possible. Avoidable with "_" (if "_"
is not used with property names). I use the underscore for visual clarity
and for better intellisense, but I also see the drawback of "hidden"
underscores for the last declaration if the "procedure separator line" is
active in the editor - but that's only one declaration and not that
important.

I use the prefix "f_". f = Field. Only for those that also have a
property.
For other fields I don't use a prefix, just like I do not use "fun_" for
functions or "prop_" for properties. Fields and other members are on the
same level, thus I don't distinguish in the usage of a prefix. But I also
make exceptions, like "txt" for textboxes (or others for controls) which
are also fields.

My 2 Eurocents.
Armin

Jan 31 '06 #15
Cor,

"Cor Ligthert [MVP]" <no************ @planet.nl> schrieb:
However this is real something special German speaking people would see.


Not really. Capitalization of initials is common in German, English, and
IIRC French, and likely other languages too.

But not the use of capitals. Just pasted from Bild without any extra
meaning for the text..

Öffentliches Interesse erregt der Patent-Motorwagen mit der
100-Kilometer-Reise von Benz’ Ehefrau Bertha, die 1888 mit dem Wagen von
Mannheim nach Pforzheim fährt. Eine „Promotion-Tour“, die Benz eine Reihe
neuer Kunden verschafft. Eine Erfolgsgeschich te beginnt. Nicht nur für
Karl Benz.


There are few exceptions. "Patent-Motorwagen" could have been written as
"Patentmotorwag en". "100-Kilometer-Reise" is written this way because of
the hyphen between "100" and "Kilometer" , otherwise it would have been
written as "Kilometerreise ". In the last few years the english language
influenced how composed words are written ("Reservereifen ablage" (correct
German) -> "Reserve-Reifen-Ablage" -> "Reserve Reifen Ablage" (incorrect
German)).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 31 '06 #16
I hate the underscore too but I still use it a lot of the time. I'm slowing
trying to break away from to and just use the

mVarName convention for module level private variables. For local variables,
I must say, I do like the descriptive name style of:
goneBad.
I no longer feel to then need to prefix the goneBad variable with it's type
prefix however (for instance, goneBad would probably be a boolean). I guess
you call this camelback? I even use this now at the method parameter level.
It's easy and descriptive.

Steve

"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:%2******** *******@TK2MSFT NGP09.phx.gbl.. .
Herfried,

I have forever hated the use of the underscore in any dataname.

Why not just mMyPrivate instead of m_MyPrivate?

Cor

Jan 31 '06 #17
Herfried, I don't read German, so I haven't read your article, but I do have
a question about your first summarized point...
* Distinction of two identifiers (property, backing field) by case only
can
lead to bugs in the implementation which cannot be easily detected. As far as I can tell, the only place in the .NET naming standard where it
says to use camelCase is for parameters. (I think there may be have been
one other variable type where they recommended camelCase, but if I remember
correctly, it was very rarely used.) So, the point you are making doesn't
appear to apply MS's naming standards.

In other words, MS never says to use camelCase for "backing field"
variables, as in the example...Private firstName As String
At least, it never says it on any official MS web page that I have found.
Here's where I have been looking.
http://msdn.microsoft.com/library/de...guidelines.asp

Is there some other reference that you are using? Do you have a particular
link that says to use camelCase for variables other than parameters? (I've
seen camelCase used inconsistently in MS's own VB.NET sample code, but this
probably has more to do with the authors of the sample code being C# people
than evidence of any particular naming standard.)

The problem I have is that MS states explicitly what naming convention to
use for Classes, Namespaces, Parameters, Methods, and Properties, but as far
as I can tell, they don't say how to name private member variables like the
private "backing field" for a property. I use a "p_" prefix to
differentiate these private member variables as those used by properties,
but this is just my convention that I use for lack of being able to find
anything definitive from MS.

Regards,

- Mitchell S. Honnert
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:uH******** *****@TK2MSFTNG P14.phx.gbl... "_AnonCowar d" <ab****@uvwxyz. com> schrieb:
: > So after three years of working in .NET and stubbornly holding on to
my
: > old hungarian notation practices--- I resolved to try to rid myself
of
: > the habit. Man, I gotta say that it is liberating!!! I love it.
:
: Well, I do not use type prefixes ("Systems Hungarian") because I use
: 'Option Strict On' most of the time. However, I use type prefixes when
: dealing with late binding (variables typed as 'Object'). Additionally
: I use the 'm_' prefix to mark private fields, and I tend to use Apps
: Hungarian because it still makes sense in strictly-typed languages.
:
: On a side note: I still refuse to use camel case for the reasons
listed
: in <URL:http://dotnet.mvps.org/dotnet/articles/camelcase/> (German
: article!).

Could you summarize the points being raised in this article for those of
us
who don't read German? Thanx,


The points made in the article are:

* Distinction of two identifiers (property, backing field) by case only
can
lead to bugs in the implementation which cannot be easily detected.

* By naming the property using pascal case and the backing field using
camel case it's harder to visually detect that both belong to each
other.
This argument is based on a human visual character recognition model.

* The naming rules described in the .NET Framework Design Guidelines
and the internal Guidelines published by Brad Abrams [MSFT] cannot be
applied to VB.NET because VB.NET is not case-sensitive.

* The first character of a word/sentence serves an important role for
word recognition. In classic typography the first letter has often
been
written in upper-case and sometimes ornamented to underline its
importance. By starting identifiers' names with a lower-case letter
while using upper-case letters inside the identifier this long
tradition
in typography is obeyed.

* Most naming guidelines are made by developers only instead of
consulting developers, psychologists, linguists, etc. who have the
scientific background to optimize naming guidelines.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 31 '06 #18
CMM
Yeah... in fact using notation with controls is exactly THE most difficult
thing in .NET. At least with variables I had a fairly nice pattern going
on.... s,i,b, etc for simple types and o for more complex types. The
notation was really just a way for me to show *instantiation* more than
anything else... a way for me to show a piece of text in my source code was
an instantiated variable rather than a static method in an Imported .NET
framework namespace or something like that.

In the new non-hungarian notation, indication of instantiation is done using
the camelCase notation. And controls receieve no notation because they are
after all just properties of the form class and properties don't get noted.
Though they do get prefixed with the Me keyword when being accessed.
Jan 31 '06 #19
CMM
I totally agree... and your example is not rare at all. In VB at least using
m_ with the underscore is practically a necessity because of VB's
case-insensitivity.
Jan 31 '06 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.