473,566 Members | 2,908 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

FxCop

I am getting a messages that I am getting. Maybe someone can help
explain some of these.
Parameter names should use complete words

Type: ParameterNamesS houldHaveComple teWords

Cause: A parameter in a public or protected method has a parameter that
meets one of the following criteria:

Rule Description
By convention, parameter names do not use abbreviations or Hungarian
notation. Naming conventions reduce the learning curve required for new
software libraries because, for very specialized types, the intended
usage is apparent from the type name. Also, naming conventions provide
a common look and feel for libraries that target the common language
runtime.

My question about this code is:

1) If I remember correct there are lots of APIs (Win32, VB etc) that
have Hungarian notation right?

2) When writing code, Hungarian notation is used to help the person
writing/reading the code to understand the type of the variable. If
you have a function that takes parameters of (Name, Value, File) then
for the entire procedure, you will be using a variable named "Value",
unless you were to first create another variable "iValue" and assign
the parameters to the new variables.

Does this make sense?

Jul 21 '05 #1
5 2951
The new Microsoft standards discourage Hungarian notation. Basically, the
reasoning is that modern IDE's have such good code insight that it is
superfluous to indicate a variables type in it's name. You can just hover
over it for a tooltip giving you that and more. So yes, whilst much old MS
code has Hungarian notation, the latest stuff doesn't (at least .NET
doesn't).

In addition, there's one other slight advantage to not using Hungarian
notation: when you change a variables type (e.g. from int to long) you don't
have to go and search for all instances of the variable to change it to the
new name. Admittedly this isn't a huge advantage with all the refactoring
tools around.

--
Sean Hederman

http://codingsanity.blogspot.com

"cmay" <cm**@walshgrou p.com> wrote in message
news:11******** **************@ c13g2000cwb.goo glegroups.com.. .
I am getting a messages that I am getting. Maybe someone can help
explain some of these.
Parameter names should use complete words

Type: ParameterNamesS houldHaveComple teWords

Cause: A parameter in a public or protected method has a parameter that
meets one of the following criteria:

Rule Description
By convention, parameter names do not use abbreviations or Hungarian
notation. Naming conventions reduce the learning curve required for new
software libraries because, for very specialized types, the intended
usage is apparent from the type name. Also, naming conventions provide
a common look and feel for libraries that target the common language
runtime.

My question about this code is:

1) If I remember correct there are lots of APIs (Win32, VB etc) that
have Hungarian notation right?

2) When writing code, Hungarian notation is used to help the person
writing/reading the code to understand the type of the variable. If
you have a function that takes parameters of (Name, Value, File) then
for the entire procedure, you will be using a variable named "Value",
unless you were to first create another variable "iValue" and assign
the parameters to the new variables.

Does this make sense?

Jul 21 '05 #2
Sean,
Thanks for the info.

Does the discouragement of Hungarian notaion extend to normal variables?

In other words is:
Dim iValue as integer
supposed to be
Dim Value as integer

Do you know if Microsoft have a doc out there explaining their standards as
it pertains to this?

Thanks again

Chris

"Sean Hederman" wrote:
The new Microsoft standards discourage Hungarian notation. Basically, the
reasoning is that modern IDE's have such good code insight that it is
superfluous to indicate a variables type in it's name. You can just hover
over it for a tooltip giving you that and more. So yes, whilst much old MS
code has Hungarian notation, the latest stuff doesn't (at least .NET
doesn't).

In addition, there's one other slight advantage to not using Hungarian
notation: when you change a variables type (e.g. from int to long) you don't
have to go and search for all instances of the variable to change it to the
new name. Admittedly this isn't a huge advantage with all the refactoring
tools around.

--
Sean Hederman

http://codingsanity.blogspot.com

"cmay" <cm**@walshgrou p.com> wrote in message
news:11******** **************@ c13g2000cwb.goo glegroups.com.. .
I am getting a messages that I am getting. Maybe someone can help
explain some of these.
Parameter names should use complete words

Type: ParameterNamesS houldHaveComple teWords

Cause: A parameter in a public or protected method has a parameter that
meets one of the following criteria:

Rule Description
By convention, parameter names do not use abbreviations or Hungarian
notation. Naming conventions reduce the learning curve required for new
software libraries because, for very specialized types, the intended
usage is apparent from the type name. Also, naming conventions provide
a common look and feel for libraries that target the common language
runtime.

My question about this code is:

1) If I remember correct there are lots of APIs (Win32, VB etc) that
have Hungarian notation right?

2) When writing code, Hungarian notation is used to help the person
writing/reading the code to understand the type of the variable. If
you have a function that takes parameters of (Name, Value, File) then
for the entire procedure, you will be using a variable named "Value",
unless you were to first create another variable "iValue" and assign
the parameters to the new variables.

Does this make sense?


Jul 21 '05 #3
I have not seen anything that defines what the inside of a method looks
like. Microsoft only wants to standardize the interface that external
system see to ensure continuity.

Here are some naming guidelines.
http://whidbey.msdn.microsoft.com/li...aa72955e80.asp

"cmay" <cm**@discussio ns.microsoft.co m> wrote in message
news:80******** *************** ***********@mic rosoft.com...
Sean,
Thanks for the info.

Does the discouragement of Hungarian notaion extend to normal variables?

In other words is:
Dim iValue as integer
supposed to be
Dim Value as integer

Do you know if Microsoft have a doc out there explaining their standards as it pertains to this?

Thanks again

Chris

"Sean Hederman" wrote:
The new Microsoft standards discourage Hungarian notation. Basically, the reasoning is that modern IDE's have such good code insight that it is
superfluous to indicate a variables type in it's name. You can just hover over it for a tooltip giving you that and more. So yes, whilst much old MS code has Hungarian notation, the latest stuff doesn't (at least .NET
doesn't).

In addition, there's one other slight advantage to not using Hungarian
notation: when you change a variables type (e.g. from int to long) you don't have to go and search for all instances of the variable to change it to the new name. Admittedly this isn't a huge advantage with all the refactoring tools around.

--
Sean Hederman

http://codingsanity.blogspot.com

"cmay" <cm**@walshgrou p.com> wrote in message
news:11******** **************@ c13g2000cwb.goo glegroups.com.. .
I am getting a messages that I am getting. Maybe someone can help
explain some of these.
Parameter names should use complete words

Type: ParameterNamesS houldHaveComple teWords

Cause: A parameter in a public or protected method has a parameter that meets one of the following criteria:

Rule Description
By convention, parameter names do not use abbreviations or Hungarian
notation. Naming conventions reduce the learning curve required for new software libraries because, for very specialized types, the intended
usage is apparent from the type name. Also, naming conventions provide
a common look and feel for libraries that target the common language
runtime.

My question about this code is:

1) If I remember correct there are lots of APIs (Win32, VB etc) that
have Hungarian notation right?

2) When writing code, Hungarian notation is used to help the person
writing/reading the code to understand the type of the variable. If
you have a function that takes parameters of (Name, Value, File) then
for the entire procedure, you will be using a variable named "Value",
unless you were to first create another variable "iValue" and assign
the parameters to the new variables.

Does this make sense?


Jul 21 '05 #4
Yep, I have found however that having one naming standard for your
parameters and one for your variables is quite a pain, so I've tended to
follow the same scheme in naming my vars. Personally, I use pascalCase for
my params and vars, and a leading underscore for class fields. The only real
reason for that is to allow me to use the same name for a param and a field:

public MyClass {
int _age;

public Class(int age) {
_age = age;
}
}

"Peter Rilling" <pe***@nospam.r illing.net> wrote in message
news:eW******** ********@TK2MSF TNGP14.phx.gbl. ..
I have not seen anything that defines what the inside of a method looks
like. Microsoft only wants to standardize the interface that external
system see to ensure continuity.

Here are some naming guidelines.
http://whidbey.msdn.microsoft.com/li...aa72955e80.asp

"cmay" <cm**@discussio ns.microsoft.co m> wrote in message
news:80******** *************** ***********@mic rosoft.com...
Sean,
Thanks for the info.

Does the discouragement of Hungarian notaion extend to normal variables?

In other words is:
Dim iValue as integer
supposed to be
Dim Value as integer

Do you know if Microsoft have a doc out there explaining their standards

as
it pertains to this?

Thanks again

Chris

"Sean Hederman" wrote:
> The new Microsoft standards discourage Hungarian notation. Basically, the > reasoning is that modern IDE's have such good code insight that it is
> superfluous to indicate a variables type in it's name. You can just hover > over it for a tooltip giving you that and more. So yes, whilst much old MS > code has Hungarian notation, the latest stuff doesn't (at least .NET
> doesn't).
>
> In addition, there's one other slight advantage to not using Hungarian
> notation: when you change a variables type (e.g. from int to long) you don't > have to go and search for all instances of the variable to change it to the > new name. Admittedly this isn't a huge advantage with all the refactoring > tools around.
>
> --
> Sean Hederman
>
> http://codingsanity.blogspot.com
>
> "cmay" <cm**@walshgrou p.com> wrote in message
> news:11******** **************@ c13g2000cwb.goo glegroups.com.. .
> >I am getting a messages that I am getting. Maybe someone can help
> > explain some of these.
> >
> >
> > Parameter names should use complete words
> >
> > Type: ParameterNamesS houldHaveComple teWords
> >
> > Cause: A parameter in a public or protected method has a parameter that > > meets one of the following criteria:
> >
> > Rule Description
> > By convention, parameter names do not use abbreviations or Hungarian
> > notation. Naming conventions reduce the learning curve required for new > > software libraries because, for very specialized types, the intended
> > usage is apparent from the type name. Also, naming conventions
> > provide
> > a common look and feel for libraries that target the common language
> > runtime.
> >
> >
> >
> > My question about this code is:
> >
> > 1) If I remember correct there are lots of APIs (Win32, VB etc) that
> > have Hungarian notation right?
> >
> > 2) When writing code, Hungarian notation is used to help the person
> > writing/reading the code to understand the type of the variable. If
> > you have a function that takes parameters of (Name, Value, File) then
> > for the entire procedure, you will be using a variable named "Value",
> > unless you were to first create another variable "iValue" and assign
> > the parameters to the new variables.
> >
> > Does this make sense?
> >
>
>
>


Jul 21 '05 #5
"Sean Hederman" <us***@blogentr y.com> wrote:
Yep, I have found however that having one naming standard for your
parameters and one for your variables is quite a pain, so I've tended to
follow the same scheme in naming my vars. Personally, I use pascalCase for
my params and vars, and a leading underscore for class fields. The only real
reason for that is to allow me to use the same name for a param and a field:

public MyClass {
int _age;

public Class(int age) {
_age = age;
}
}

In more recent years some of the C++ community moved to the
trailing underscore as library vendors have had the habit of
using the underscore prefix for library
specific/non-portable variables, function names and macros.
So in some books from the 1990s you'll see:

m_age (short for member variable "age")

which later transforms to

_age (lazy typist I guess)

to

age_ (avoiding any potential interference with
vendor libraries).

You really don't need it as you can write:

this.age = age;

however the lazy typist in me still prefers

age_ = age

plus I think there is some value to identifying an instance
variable at a glance without being forced to write
"this.age" everytime (Which begs the question: should you
distinguish between instance and class variables
("static")?) . However seeing code like

age_.ToString()

may take some getting used to.
'Any fool can write code that a computer can understand.
Good programmers write code that humans can understand.'
Martin Fowler,
'Refactoring: improving the design of existing code', p.15
Jul 21 '05 #6

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

Similar topics

0
1506
by: Crocker Data Processing | last post by:
Hi. I've written a bunch of custom rules for FxCop version 1.23, and today happened to download and install (separately) the new FxCop 1.321. Arrgghh ! The new introspection stuff is a lot nicer, but I will have to move my rules over. Fair enough, but I notice that there is still no documentation for the SDK, I understand that's...
5
1758
by: Chua Wen Ching | last post by:
I had use fxcop to check my code. I had 1 confusion here. I would normally call a method by this way in my IAnimal: Example: public void CallFuncA(ushort port); But fxcop says i need to write like a property rather than method to this:
0
1301
by: Chua Wen Ching | last post by:
Hi there, I am super confuse on this recommendation by FxCop. 1) http://www.gotdotnet.com/team/fxcop/docs/rules/UsageRules/OperatorEqualsOverridesRequireEqualsOverridel.html First of all, let me explain how i see that problem: I had a C program that does this:
3
3425
by: Rasmus | last post by:
I VS 2005 beta 2 i have a solution with - a number of classes - a website - a httphandler - a http module I want to run fxcop on my class files - but cant find out how to enable it. I've looked at http://msdn2.microsoft.com/library/ms182066(en-us,vs.80).aspx
8
1892
by: hansiman | last post by:
Just beginning using FxCop in my asp.net projects... I get a lot of error messages under the header: AvoidUnusedParameters for funtions and routines lik: Sub isUserAuthenticated(ByVal blnLoggedIn As Boolean) If Not (blnLoggedIn) Then System.Web.HttpContext.Current.Response.Redirect(pcPageLogin) End If
3
2240
by: Velvet | last post by:
I ran FxCop on one of the components for my web site and the security rules what me to add " tags like the ones listed below: This breaks my ASP.NET application. So my question is, what should these
4
379
by: Bruce One | last post by:
Given a project with some .cs files, Is there a way to block some of these files to be read by FxCop ?
10
1695
by: Karsten Schramm | last post by:
I would write BaseClass var; ..... if(var is DerivedClass) { DerivedClass derivedVar = (DerivedClass)var; DoSomething(derivedVar); }
5
5079
by: Peter Ritchie [C# MVP] | last post by:
I've purposely been ignoring a CA2122 warning in some C++ interop code I've been working on for quite some time. I've just recently had the cycles to investigate the warning. The warning message is as follows Warning CA2122 : Microsoft.Security : MyClass.Method():Void calls into Marshal.GetExceptionPointers():IntPtr which has a LinkDemand....
3
4373
by: AlexS | last post by:
When I implement Dispose pattern in object implementing IDisposable, current fxcop recommends: Ensure that Wrapper.Dispose():Void is declared as public and sealed. However, if I do as it asks, compiler complains that sealed can't be used because method is not overrideable. I believe sealed isn't applicable here at all. And this rule...
0
7666
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...
0
7584
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...
0
7888
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. ...
0
8108
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7644
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6260
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...
0
3643
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...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
925
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...

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.