Naming conventions on parameters of private functions and variables?

  • Thread starter Thread starter Cristof Falk
  • Start date Start date
C

Cristof Falk

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.
 
Cristof said:
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.
 
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
 
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
 
fbhcah said:
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/d...s/cpgenref/html/cpconcapitalizationstyles.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.
 
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.
---------
 
Back
Top