Go Back   Velocity Reviews > Newsgroups > MCSD
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

MCSD - Hungarian notation in .NET

 
Thread Tools Search this Thread
Old 10-13-2003, 07:07 AM   #1
Default Hungarian notation in .NET


I'm curious...

I've been wondering why I haven't seen any Hungarian notation used in
variable/object names when looking at programming examples in any .NET
training literature.

I've always had hammered in my head to use two or three letter
prefixes such as txtFirstName, intCounter, cnEmployees, for a text
box, integer data type, and connection object, etc... for VB coding.
I think there are "standards" for different programming
languages/environments, and I've tended to follow them, especially
since other coders may have to maintain your code, and it's a lot
easier to identify what variables/objects actually are if you prefix
them IMHO.

Also, my MCT for VB 6 went to a .NET MOC training course, and he said
the MOC didn't have any prefixes/mnemonics in any of the coding
examples. Is this something that .NET is getting away from???

Kael


Kael V. Dowdy
  Reply With Quote
Old 10-13-2003, 07:40 AM   #2
Kline Sphere
 
Posts: n/a
Default Re: Hungarian notation in .NET
You are free to define any coding standards and practices you wish,
the importance points to keep in mind are consistency and relevance.

My on view is that Hungarian notation is rather pointless within
modern object oriented practices given that a 'name' should be self
describing and relate back to the actual type. Even in procedural C, I
found some really funny examples of Hungarian notation usage,e.g. how
would you represent an array of functions pointer (which accept an
array of longs) which return and array of functions pointers which
return an array of vectors?

>I'm curious...
>
>I've been wondering why I haven't seen any Hungarian notation used in
>variable/object names when looking at programming examples in any .NET
>training literature.
>
>I've always had hammered in my head to use two or three letter
>prefixes such as txtFirstName, intCounter, cnEmployees, for a text
>box, integer data type, and connection object, etc... for VB coding.
>I think there are "standards" for different programming
>languages/environments, and I've tended to follow them, especially
>since other coders may have to maintain your code, and it's a lot
>easier to identify what variables/objects actually are if you prefix
>them IMHO.
>
>Also, my MCT for VB 6 went to a .NET MOC training course, and he said
>the MOC didn't have any prefixes/mnemonics in any of the coding
>examples. Is this something that .NET is getting away from???




Kline Sphere
  Reply With Quote
Old 10-13-2003, 08:53 AM   #3
Maria
 
Posts: n/a
Default Re: Hungarian notation in .NET
>I haven't seen any Hungarian notation
....
>Is this something that .NET is getting away from???


Yes, with .Net they have dropped the hungarian notation.

http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpgenref/html/cpconparameternamingguidelines.asp

Naming conventions are a pain to enforce but a real time
saver for the people who need to maintain the code later
on. There is a nice customisable utility called FxCop that
inspects your .net assemblies for for conformance to the
Microsoft .NET Framework Design Guidelines:
http://www.gotdotnet.com/team/fxcop/


>-----Original Message-----
>You are free to define any coding standards and practices

you wish,
>the importance points to keep in mind are consistency and

relevance.
>
>My on view is that Hungarian notation is rather pointless

within
>modern object oriented practices given that a 'name'

should be self
>describing and relate back to the actual type. Even in

procedural C, I
>found some really funny examples of Hungarian notation

usage,e.g. how
>would you represent an array of functions pointer (which

accept an
>array of longs) which return and array of functions

pointers which
>return an array of vectors?
>
>>I'm curious...
>>
>>I've been wondering why I haven't seen any Hungarian

notation used in
>>variable/object names when looking at programming

examples in any .NET
>>training literature.
>>
>>I've always had hammered in my head to use two or three

letter
>>prefixes such as txtFirstName, intCounter, cnEmployees,

for a text
>>box, integer data type, and connection object, etc...

for VB coding.
>>I think there are "standards" for different programming
>>languages/environments, and I've tended to follow them,

especially
>>since other coders may have to maintain your code, and

it's a lot
>>easier to identify what variables/objects actually are

if you prefix
>>them IMHO.
>>
>>Also, my MCT for VB 6 went to a .NET MOC training

course, and he said
>>the MOC didn't have any prefixes/mnemonics in any of the

coding
>>examples. Is this something that .NET is getting away

from???
>
>.
>



Maria
  Reply With Quote
Old 10-13-2003, 03:55 PM   #4
Kael V. Dowdy
 
Posts: n/a
Default Re: Hungarian notation in .NET
> >-----Original Message-----
> >You are free to define any coding standards and practices

> you wish,
> >the importance points to keep in mind are consistency and

> relevance.


Very true...

> >
> >My on view is that Hungarian notation is rather pointless

> within
> >modern object oriented practices given that a 'name'

> should be self
> >describing and relate back to the actual type. Even in


Yes, you are right...I feel too that names should be self subscribing
(something that the .NET base class library namespaces did pretty
well, WTG MS!)

> procedural C, I
> >found some really funny examples of Hungarian notation

> usage,e.g. how
> >would you represent an array of functions pointer (which

> accept an
> >array of longs) which return and array of functions

> pointers which
> >return an array of vectors?
> >


That'd be a really funny and long name, huh?

"Maria" <> wrote in message news:<07de01c3915f$083d94c0$>...
> >I haven't seen any Hungarian notation

> ...
> >Is this something that .NET is getting away from???

>
> Yes, with .Net they have dropped the hungarian notation.
>
> http://msdn.microsoft.com/library/default.asp?
> url=/library/en-
> us/cpgenref/html/cpconparameternamingguidelines.asp


I checked this out, gotta spend some more time perusing through this
section of MSDN.

>
> Naming conventions are a pain to enforce but a real time
> saver for the people who need to maintain the code later
> on. There is a nice customisable utility called FxCop that
> inspects your .net assemblies for for conformance to the
> Microsoft .NET Framework Design Guidelines:
> http://www.gotdotnet.com/team/fxcop/


FxCop looks like a really cool too...gotta check it out!

> >
> >>I'm curious...
> >>
> >>I've been wondering why I haven't seen any Hungarian

> notation used in
> >>variable/object names when looking at programming

> examples in any .NET
> >>training literature.
> >>
> >>I've always had hammered in my head to use two or three

> letter
> >>prefixes such as txtFirstName, intCounter, cnEmployees,

> for a text
> >>box, integer data type, and connection object, etc...

> for VB coding.
> >>I think there are "standards" for different programming
> >>languages/environments, and I've tended to follow them,

> especially
> >>since other coders may have to maintain your code, and

> it's a lot
> >>easier to identify what variables/objects actually are

> if you prefix
> >>them IMHO.
> >>
> >>Also, my MCT for VB 6 went to a .NET MOC training

> course, and he said
> >>the MOC didn't have any prefixes/mnemonics in any of the

> coding
> >>examples. Is this something that .NET is getting away

> from???
> >
> >.
> >



Kael V. Dowdy
  Reply With Quote
Old 10-13-2003, 06:49 PM   #5
Jaime
 
Posts: n/a
Default Hungarian notation in .NET
It's used for the (name) property.
>-----Original Message-----
>I'm curious...
>
>I've been wondering why I haven't seen any Hungarian

notation used in
>variable/object names when looking at programming

examples in any .NET
>training literature.
>
>I've always had hammered in my head to use two or three

letter
>prefixes such as txtFirstName, intCounter, cnEmployees,

for a text
>box, integer data type, and connection object, etc... for

VB coding.
>I think there are "standards" for different programming
>languages/environments, and I've tended to follow them,

especially
>since other coders may have to maintain your code, and

it's a lot
>easier to identify what variables/objects actually are if

you prefix
>them IMHO.
>
>Also, my MCT for VB 6 went to a .NET MOC training course,

and he said
>the MOC didn't have any prefixes/mnemonics in any of the

coding
>examples. Is this something that .NET is getting away

from???
>
>Kael
>.
>



Jaime
  Reply With Quote
Old 10-15-2003, 04:16 AM   #6
Jay Walters
 
Posts: n/a
Default Hungarian notation in .NET
Another reason why - is because everything is strongly
typed.. generic objects and type-casting are less
frequent.

Most people will use mObjectName and cObjectName to
represent class level objects, functions and property
instances just represent what you're doing.

dim consultRows as DataRow()




>-----Original Message-----
>I'm curious...
>
>I've been wondering why I haven't seen any Hungarian

notation used in
>variable/object names when looking at programming

examples in any .NET
>training literature.
>
>I've always had hammered in my head to use two or three

letter
>prefixes such as txtFirstName, intCounter, cnEmployees,

for a text
>box, integer data type, and connection object, etc...

for VB coding.
>I think there are "standards" for different programming
>languages/environments, and I've tended to follow them,

especially
>since other coders may have to maintain your code, and

it's a lot
>easier to identify what variables/objects actually are

if you prefix
>them IMHO.
>
>Also, my MCT for VB 6 went to a .NET MOC training

course, and he said
>the MOC didn't have any prefixes/mnemonics in any of the

coding
>examples. Is this something that .NET is getting away

from???
>
>Kael
>.
>



Jay Walters
  Reply With Quote
Old 10-15-2003, 12:36 PM   #7
Simon Smith
 
Posts: n/a
Default Re: Hungarian notation in .NET
On Tue, 14 Oct 2003 20:16:08 -0700 in article
<2b00f01c392ca$ad3ad930$> in
microsoft.public.cert.exam.mcsd , "Jay Walters"
<> wrote:

>Another reason why - is because everything is strongly
>typed.. generic objects and type-casting are less
>frequent.
>
>Most people will use mObjectName and cObjectName to
>represent class level objects, functions and property
>instances just represent what you're doing.
>
>dim consultRows as DataRow()
>


I'm not sure you're right about mObjectName and cObjectName. Our shop
follows the MS recommendations for .NET and thus we don't use them at
all. (On a side note, I never did myself.)


--
Simon
simon dot smith at snowvalley dot com
"Insomnia is a small price to pay for the stuff you read on UseNet"


Simon Smith
  Reply With Quote
Old 10-15-2003, 07:44 PM   #8
Jay Walters
 
Posts: n/a
Default Re: Hungarian notation in .NET
That's the thing, this isn't about right or wrong, it's
all preference.

The Microsoft way seems to be regular Camel Case and no
prefixes, (even though VS control names default to pascal
case).

But many people find it nicer to use a prefix for class
fields. Using 'm' and 'c' for example allows intellisense
to group all of your objects. Most of the MSFT people I
know use just a '_' --> string _connString;

Some people are also fanatical about using Base. and Me.

The most important thing in all of this is to be
consistant within your projects.

For more information about namimg guidelines:

http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpgenref/html/cpconpropertynamingguidelines.asp





>
>I'm not sure you're right about mObjectName and

cObjectName. Our shop
>follows the MS recommendations for .NET and thus we

don't use them at
>all. (On a side note, I never did myself.)
>
>
>--
>Simon
>simon dot smith at snowvalley dot com
>"Insomnia is a small price to pay for the stuff you read

on UseNet"
>.
>



Jay Walters
  Reply With Quote
Old 10-15-2003, 08:31 PM   #9
Kline Sphere
 
Posts: n/a
Default Re: Hungarian notation in .NET
On Wed, 15 Oct 2003 11:44:56 -0700, "Jay Walters"
<> wrote:

>That's the thing, this isn't about right or wrong, it's
>all preference.


.... And consistence within an organization.

>Most of the MSFT people I
>know use just a '_' --> string _connString;


Been a common approach taken to indicate 'private' members for as long
as I can remember.


Kline Sphere
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
.NET 2.0 Web Apps / .NET 3.5 ASP.NET Apps - Differences/Similariti london1919 MCTS 1 12-08-2008 03:16 PM
Exam strategy and references for MCTS .net (536+528)/how to prepare gravz84 MCTS 0 06-20-2008 11:32 AM
RE: .NET 3.0 Certification / Exams Joel MCTS 1 03-28-2007 03:05 AM
RE: .NET 3.0 Certification / Exams Joel MCITP 1 03-28-2007 03:05 AM
RE: .NET 3.0 Certification / Exams swapnil2006 MCITP 0 12-22-2006 10:23 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46