473,382 Members | 1,238 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Naming conventions on parameters of private functions and variables?

MS recommends keeping Hungarian notation off parameters for
public/protected methods. Is the best practice to do so for private as
well? It seems that consistency would indicate all should be
non-Hungarian, but I'm not sure how well-adopted the "no Hungarian on
parameters" is.

And for variable naming, is Hungarian still regularly used, or has
that been abandoned as well?

Thanks.
Nov 16 '05 #1
6 2246
Cristof Falk wrote:
MS recommends keeping Hungarian notation off parameters for
public/protected methods. Is the best practice to do so for private as
well?
Personally, I don't think that /good/ C# code benefits from Hungarian
notation at all. If you write more, shorter methods and more, shorter
classes, the code doesn't need any kind of type prefixes. I'd go so far
as to say that *any* prefixes decrease readability.

Variables should be named so that one could read them aloud and
instantly understand their purpose.

As for using Hungarian notation only for private data, that'd give a
additional disadvantage that your code is inconsistent.
It seems that consistency would indicate all should be
non-Hungarian, but I'm not sure how well-adopted the "no Hungarian on
parameters" is.

And for variable naming, is Hungarian still regularly used, or has
that been abandoned as well?

Nov 16 '05 #2
Thanks. That's what I thought was the intentions of consistent naming,
but wanted a sanity check before I go telling team members that
they're so very far from the standards! -cf

On Sat, 10 Apr 2004 13:15:55 +0100, C# Learner <cs****@learner.here>
wrote:
Cristof Falk wrote:
MS recommends keeping Hungarian notation off parameters for
public/protected methods. Is the best practice to do so for private as
well?


Personally, I don't think that /good/ C# code benefits from Hungarian
notation at all. If you write more, shorter methods and more, shorter
classes, the code doesn't need any kind of type prefixes. I'd go so far
as to say that *any* prefixes decrease readability.

Variables should be named so that one could read them aloud and
instantly understand their purpose.

As for using Hungarian notation only for private data, that'd give a
additional disadvantage that your code is inconsistent.
It seems that consistency would indicate all should be
non-Hungarian, but I'm not sure how well-adopted the "no Hungarian on
parameters" is.

And for variable naming, is Hungarian still regularly used, or has
that been abandoned as well?


Nov 16 '05 #3
Hi Cristo,

MS recommends Hungarian notation only for static fields.

IMHO, it's best to use non-hungarian for all exposed fields, properties,
methods etc. because this adds clarity for developers who use our types.
(For eg. think about Intellisense displaying hungarian based entities -
that's something which won't be very attractive).

Within the type definition though, you might use any notation you want.

HTH,
fbhcah
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #4
fbhcah wrote:
Hi Cristo,

MS recommends Hungarian notation only for static fields.
Huh? It reads, "Do not use a Hungarian notation prefix on static field
names." at:

http://msdn.microsoft.com/library/de...tionstyles.asp
-or-
http://tinyurl.com/26m8b
IMHO, it's best to use non-hungarian for all exposed fields, properties,
methods etc. because this adds clarity for developers who use our types.
(For eg. think about Intellisense displaying hungarian based entities -
that's something which won't be very attractive).

Within the type definition though, you might use any notation you want.


That causes the problem of inconsistency, though.
Nov 16 '05 #5
You are correct. There is NO hungarian notation recommendations in any of
the naming standards for .NET from Microsoft.

--
-----
Sam Gentile
Microsoft MVP - C#/.NET
..NET Blog http://samgentile.com/blog/

Please do NOT contact me directly but respond to
the newsgroup instead.
---------
"C# Learner" <cs****@learner.here> wrote in message
news:Oy**************@TK2MSFTNGP10.phx.gbl...
fbhcah wrote:
Hi Cristo,

MS recommends Hungarian notation only for static fields.


Huh? It reads, "Do not use a Hungarian notation prefix on static field
names." at:

http://msdn.microsoft.com/library/de...tionstyles.asp
-or-
http://tinyurl.com/26m8b
IMHO, it's best to use non-hungarian for all exposed fields, properties,
methods etc. because this adds clarity for developers who use our types.
(For eg. think about Intellisense displaying hungarian based entities -
that's something which won't be very attractive). Within the type
definition though, you might use any notation you want.


That causes the problem of inconsistency, though.

Nov 16 '05 #6
Hey - the problem was this! I found out an inconsistancy in MSDN online
and the MSDN CD.

Check these links which are the same topics but one which states to use
Hungarian notation (CD), and the other which states not to (online).

ms-help://MS.VSCC/MS.MSDNVS/cpgenref/html/cpconstaticfieldnamingguidelin
es.htm

http://msdn.microsoft.com/library/de.../en-us/cpgenre
f/html/cpconstaticfieldnamingguidelines.asp
HTH,
fbhcah
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #7

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

Similar topics

5
by: Ted | last post by:
I'm trying to come up with naming conventions for my company as we move to C#. I'm looking through the Naming Guidelines section on MSDN, but I'm unable to find a recommendation for class scope...
4
by: Cristof Falk | last post by:
I wanted to get a feel. The documentation gives naming conventions for public/protected members. Is this truly widely adopted? And what about using the same conventions for private members and...
6
by: Cristof Falk | last post by:
MS recommends keeping Hungarian notation off parameters for public/protected methods. Is the best practice to do so for private as well? It seems that consistency would indicate all should be...
4
by: Mark Broadbent | last post by:
stupid question time again to most of you experts but this is something that continually bothers me. I am trying to get into the habit of naming variables and controls in an assembly as per...
48
by: Robert Jacobson | last post by:
Hello all, If I have a class called "Foo," is there a preferred naming convention for iterating through each Foo instance in a collection of Foos? I've seen several different variations, even...
5
by: rastaman | last post by:
Hi all, I know of the existence of Object Naming Conventions for Visual Basic 6. Now I'm reading some books about VB .NET, but the names used for the objects are button1, picturebox1, etc. I...
0
by: Carl Colijn | last post by:
Hi all, Disclaimer: before I might trigger your "let's start a holy war!" button, I'd like to say I'm not intended to; I just post this message to get some input and not to promote "Yet Another...
114
by: Jonathan Wood | last post by:
I was just wondering what naming convention most of you use for class variables. Underscore, "m_" prefix, camel case, capitalized, etc? Has one style emerged as the most popular? Thanks for...
23
by: Thorsten Kampe | last post by:
Okay, I hear you saying 'not another naming conventions thread'. I've read through Google and the 'naming conventions' threads were rather *spelling conventions* threads. I'm not interested...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.