Re: Naming Conventions dot net/csharp

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Jon Skeet [C# MVP] (skeet_at_pobox.com)
Date: 04/16/04


Date: Fri, 16 Apr 2004 14:36:19 +0100

Mark Broadbent <no-spam-please@no-spam-please.com> wrote:
> 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.

The main one is

http://tinyurl.com/2cun

> 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 or between different articles.
> For instance, in one article it stated that class private and protected
> variables should be named underscore+camelcase e.g. _likeThis
> But I never seem to come across this in peoples' code samples (whether MS
> employee or not).

Protected variables need to follow a public naming convention, but for
private variables and methods you can use your own convention.
Personally I don't use any prefixes or anything, but lots of others do.

> Another ambigious thing I have noticed (even steming back to VB conventions)
> is that when naming controls, I dont seem to find a standard for radiobutton
> (i.e. something like rdoMyButton).
>
> So in brief what I am looking for is.....
> Naming standards for everything throughout an Assembly. Additionally full
> standards as far as is possible for controls.

Well, MS only specify *public* naming conventions, but you'll find
plenty of differing opinions about other stuff. It's important that you
or your company standardises on a naming convention for private stuff,
but it doesn't matter too much what that convention is.

> Also could someone clarify
> whether class Naming convention is applied to the design time element, the
> instance or both.

Not sure what you mean here - could you clarify?

> Finally could someone give me conventions for the solution
> explorer elements such as the code files *.cs

That's really up to you/your company - it won't make much odds to the
outside world. Actually, that's not quite true - if you're writing a
library which implements a certain namespace, it's conventional to name
the assembly by the namespace, eg Foo.Bar.dll for namespace Foo.Bar.

-- 
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Quantcast