473,396 Members | 1,676 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 regularly followed?

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
variables?

My coding preference is to use this everywhere (banish Hungarian and
follow the capitalization rules) but I need to sell it to team
members.

Thanks!
Nov 22 '05 #1
4 1763
Cristof Falk <cf**@critterdesign.net> wrote:
I wanted to get a feel. The documentation gives naming conventions for
public/protected members. Is this truly widely adopted?
Pretty widely, yes.
And what about using the same conventions for private members and
variables?
I personally do, yes - but it's less widely followed than the
public/protected one is.
My coding preference is to use this everywhere (banish Hungarian and
follow the capitalization rules) but I need to sell it to team
members.


I certainly haven't seen any particularly good reasons *not* to, and I
find code without prefixes etc much more readable. The only thing you
need to beware of (IME) is making sure that your properties access the
variable, rather than recursing, eg:
// Careful of this
int foo;
public int Foo
{
get { return Foo; }
set { Foo = value; }
}

// ... you want this instead
int foo;
public int Foo
{
get { return foo; }
set { foo = value; }
}

However, it's very easy to find such problems, and I can only remember
doing it once myself.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #2
Cristof Falk <cf**@critterdesign.net> wrote:
I wanted to get a feel. The documentation gives naming conventions for
public/protected members. Is this truly widely adopted?
Pretty widely, yes.
And what about using the same conventions for private members and
variables?
I personally do, yes - but it's less widely followed than the
public/protected one is.
My coding preference is to use this everywhere (banish Hungarian and
follow the capitalization rules) but I need to sell it to team
members.


I certainly haven't seen any particularly good reasons *not* to, and I
find code without prefixes etc much more readable. The only thing you
need to beware of (IME) is making sure that your properties access the
variable, rather than recursing, eg:
// Careful of this
int foo;
public int Foo
{
get { return Foo; }
set { Foo = value; }
}

// ... you want this instead
int foo;
public int Foo
{
get { return foo; }
set { foo = value; }
}

However, it's very easy to find such problems, and I can only remember
doing it once myself.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #3
> 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
variables?

private variables should always start with a lowercase letter (some people
are swearing on a leading underscore to distinguish between variable and
property).
but naming conventions for private stuff is not so important since it is not
part of your api,
and naming changes in private members does not affect client code.
anyway, one should always follow naming conventions, public or private.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
Nov 22 '05 #4
> 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
variables?

private variables should always start with a lowercase letter (some people
are swearing on a leading underscore to distinguish between variable and
property).
but naming conventions for private stuff is not so important since it is not
part of your api,
and naming changes in private members does not affect client code.
anyway, one should always follow naming conventions, public or private.

--
cody

[Freeware, Games and Humor]
www.deutronium.de.vu || www.deutronium.tk
Nov 22 '05 #5

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

Similar topics

2
by: Steven D'Aprano | last post by:
Are there any useful naming conventions for modules, classes and functions? For instance, should I name functions as verbs and classes as nouns? eg class Transformer(): pass def...
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...
6
by: Cristof Falk | last post by:
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...
4
by: Mark Broadbent | last post by:
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...
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...
18
by: psbasha | last post by:
Hi, I would like to know what naming conventions we can follow for the following types of variables/sequences : Variables : ------------- Integer Float Boolean
8
by: mrashidsaleem | last post by:
Can anyone guide me what is wrong with the naming conventions suggested below? I know that this is not recommended by many (including Microsoft) but I need to know what exactly is the rationale...
5
by: howa | last post by:
I have been using for Java for a long time, now need to write some C+ +, It seems to me that naming conventnio in C++ is quite different from Java (in fact, any recommended standard?) e.g....
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
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
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...
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
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.