Re: Coding Conventions for C#

From: mikeb (mailbox.google_at_mailnull.com)
Date: 02/26/04


Date: Wed, 25 Feb 2004 16:42:29 -0800

Andrea Williams wrote:
> Responding to this link in an old thread:
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/ht
> ml/cpconnetframeworkdesignguidelines.asp
>
> According to that naming convention, a parameter should be be named like
> this "typeName" (ei stringFirstName). The types that they list add to the
> variable name and the amount of typing to do by quite a lot when compounded
> by the amount of code that goesinto creating an app. Is there anyone still
> using the hungarian convention or a variation of it?

I think you're getting a bit confused on what they're advocating - they
don't suggest prefixing parameter names with the type of the parameter.
  Note that in the example they give, the typeName parameter is a string
type, but they didn't call it stringName.

The guidelines explicitly say:

================================================
Use names that describe a parameter's meaning rather than names that
describe a parameter's type. Development tools should provide meaningful
information about a parameter's type. Therefore, a parameter's name can
be put to better use by describing meaning. Use type-based parameter
names sparingly and only where it is appropriate.
================================================

>
> Even though the hungarian convention is supposedly no longer considered good
> in the Naming Conventions for Microsoft, I'm considering using it just to
> cut down and the amount of typing. Any programmer is going to know what it
> means and it will cut down on the amount of code.
>
> Maybe there's a good reason for typing out the whole data type word,
> anyone??
>
> I would also prefer to perfix private members with something. VB used "m_"
> and it looks like c++ did as well, although it may be a little messy... I
> think I like just the underscore only, "_".
>
> Also, I believer the basic reason that the hungarian notation is out is due
> to the fact that VS.NET is strongly typed. But that only helps you IF you
> are using VS.NET. If you're using some other program, say like Notepad, you
> wouldn't have the benefit of iintellisense and I would think that the
> hungarian notation would still be valuable.
>
> Any other thoughts?
>
> I have the task of setting up our company naming and coding conventions and
> I would like extra input before I settle on one specific set of guidlines.
>
> Thanks in advance,
>
> Andrea Williams
>
>

-- 
mikeb


Relevant Pages

  • Re: How a delete a object from DOM ?
    ... why you would want to use javascript outside of such a domain. ... their "natural" meaning. ... for speed and the use of any particular naming convention. ...
    (comp.lang.javascript)
  • Re: Essay on PID Motor control
    ... > go overboard on the math, I do think that a few simple, well-chosen ... I think it is a great convention because I know, ... is a zero terminated string, pVar is a pointer to a var, etc. ... any naming convention for that matter does take time to get used too, ...
    (comp.robotics.misc)
  • Re: Naming Conventions dot net/csharp
    ... private variables and methods you can use your own convention. ... > Naming standards for everything throughout an Assembly. ... or your company standardises on a naming convention for private stuff, ...
    (microsoft.public.dotnet.languages.csharp)
  • Coding Conventions for C#
    ... According to that naming convention, a parameter should be be named like ... by the amount of code that goesinto creating an app. ... Even though the hungarian convention is supposedly no longer considered good ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Naming Conventions dot net/csharp
    ... explain why the class level vars and controls conventions differ so much ... apply the naming convention to a class, ... that say for example I am using PascalCase for my class FooBar does it ...
    (microsoft.public.dotnet.languages.csharp)