473,830 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2279
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******** ******@TK2MSFTN GP10.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/cpconstaticfiel dnamingguidelin
es.htm

http://msdn.microsoft.com/library/de.../en-us/cpgenre
f/html/cpconstaticfiel dnamingguidelin es.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
1893
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 variables. Working with WinForms, I believe it would be helpful to have some type of prefix. In Visual Basic we used m_variableName. But I can't find any suggestions on this. Any help on this would be great. Thanks,
4
320
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 variables? My coding preference is to use this everywhere (banish Hungarian and follow the capitalization rules) but I need to sell it to team members.
6
392
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 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.
4
7151
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 convensions. The thing is that Ive never really get the full reference to check against. Ive seen a couple of articles, but there always seems to be a bit missing. I also always seem to run into conflicting convensions both in code samples themselves...
48
1808
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 in the MSDN documentation: #1: For each Foo as Foo in Foos ...
5
6178
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 wonder if I can use the same naming conventions as for VB6 ? If so, what about the names for the new objects in .NET. Kind regards rastaman
0
1748
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 Naming Convention". It's a bit of a long post, but I've spent the past few days on perfecting this, finally came to the conclusion that maybe I went a bit overboard with it, almost willing to just say "the @#$ with it" but I didn't want to let it...
114
7892
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 any comments. --
23
2445
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 in camelCase versus camel_case or anything mentioned in 'PEP 8 -- Style Guide for Python Code'. What I'm looking for is hints or ideas how to name your variables and especially how to name functions, methods and classes.
0
9793
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9642
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10774
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9315
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7746
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6951
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5617
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3959
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3076
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.