473,396 Members | 2,023 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Naming Conventions dot net/csharp

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 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).
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. Also could someone clarify
whether class Naming convention is applied to the design time element, the
instance or both. Finally could someone give me conventions for the solution
explorer elements such as the code files *.cs

Thanks!
--

Br,
Mark Broadbent
mcdba , mcse+i
=============
Nov 16 '05 #1
4 7126
Mark Broadbent <no************@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 - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2
yeah thanks. Id seen that one before but feel it is missing an awful lot
(such as control, private members etc). The other good link Id found was
http://www.irritatedvowel.com/Progra...Standards.aspx
but that doesnt give a prefix for each control (although it states name them
in Hungarian style).
I'd hoped that for something I consider important that a "bible" would exist
somewhere?

personally I would prefer the Editor to apply a formatting template to the
variable /class/ interface/ control etc.
e.g I create a texbox it creates name txtTextbox1 where txt is implied by
the control and cant be removed -and the camel casing cannot be changed
although the text "Textbox1" can. Or a private class variable is created so
_ is implied and is prefix to (and cant be changed) the variable text (which
is also enforced to be Pascal case.
I think this would speed development up hugely. For companies that enforce
there own standards, templates could be modified....The option to turn off
this behaviour could also exist.
Whether or not this is in Whidbey I will live in hope

--

--

Br,
Mark Broadbent
mcdba , mcse+i
=============
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Mark Broadbent <no************@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 - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #3
just seen the rest of your reply (didnt scroll down!). Yes that would
explain why the class level vars and controls conventions differ so much
(cos there aint a set standard). just constantly find myself changing my
mind about how and what I call something (which is probably the worst thing
I can do).

You wanted me to clarify what I was going on about when I mention would I
apply the naming convention to a class, instance or both. What I meant is
that say for example I am using PascalCase for my class FooBar does it
follow that I should also use Pascal casing for any instances of that class

class FooBar
{...}

class App
{
private FooBar AnotherFoo=new FooBar();
public FooBar PubFoo=new FooBar();
.....
}

because in this example there is a public object and a private one.
--

--

Br,
Mark Broadbent
mcdba , mcse+i
=============
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Mark Broadbent <no************@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 - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #4
Mark Broadbent <no************@no-spam-please.com> wrote:
just seen the rest of your reply (didnt scroll down!). Yes that would
explain why the class level vars and controls conventions differ so much
(cos there aint a set standard). just constantly find myself changing my
mind about how and what I call something (which is probably the worst thing
I can do).

You wanted me to clarify what I was going on about when I mention would I
apply the naming convention to a class, instance or both. What I meant is
that say for example I am using PascalCase for my class FooBar does it
follow that I should also use Pascal casing for any instances of that class

class FooBar
{...}

class App
{
private FooBar AnotherFoo=new FooBar();
public FooBar PubFoo=new FooBar();
....
}

because in this example there is a public object and a private one.
--


No. There's no such thing as a public object and a private one - there
are only private and public *members*.

I would suggest only having public fields which are readonly, and
treating them like other constants, i.e. using Pascal casing. I can't
immediately think of any public members which wouldn't use Pascal
casing, in fact.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #5

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

Similar topics

4
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...
7
by: cmiddlebrook | last post by:
Hi there, I keep finding myself getting inconsistent with naming conventions for things like member variables, class names etc and I just want to find something that suits me and stick to it. I...
1
by: clintonG | last post by:
Does the use of DTD, XML Schema and similar constructs adopt the use of C# naming conventions? If so how do I make the distinction of how to apply C# conventions with XML elements, attributes and...
3
by: C# Learner | last post by:
Why can't people abide by naming conventions?! It seems that most people have to have their /own/ custom convention.
3
by: clintonG | last post by:
Does the use of DTD, XML Schema and similar constructs adopt the use of C# naming conventions? If so how do I make the distinction of how to apply C# conventions with XML elements, attributes and...
5
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...
9
by: kevininstructor | last post by:
Greetings, I am in the process of creating naming conventions for VB.NET controls i.e. CheckBox -> chkShowThisOnStartup ListBoxt -> lstSomeList What I am looking for other developers...
35
by: Smithers | last post by:
Is it common practise to begin the name of form classes with "frm" (e.g., frmOneForm, frmAnotherForm). Or is that generally considered an outdated convention? If not "frm" what is a common or...
1
by: Philipp Post | last post by:
Marcello, Not a big surprise as naming conventions have a lot to do with personal prefernces. There are a lot of threads in comp.databases and the other database groups. Just do a search for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.