473,830 Members | 2,241 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1792
Cristof Falk <cf**@critterde sign.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.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 22 '05 #2
Cristof Falk <cf**@critterde sign.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.co m>
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
3044
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 transform(): do_stuff
4
320
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 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.
7
2490
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 am wondering if there are any naming conventions around that are deemed suitable by the general C++ community. I have googled around and I can't find much - mostly long lists of hungarian-like prefixes which is not really what I'm after.
1
6553
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 so on? Any referrals to resources that discuss or document XML Naming Conventions? -- <%= Clinton Gallagher, "Twice the Results -- Half the Cost" Architectural & e-Business Consulting -- Software Development NET...
6
2279
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 non-Hungarian, but I'm not sure how well-adopted the "no Hungarian on parameters" is. And for variable naming, is Hungarian still regularly used, or has that been abandoned as well? Thanks.
4
7151
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 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...
3
4355
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 so on? Any referrals to resources that discuss or document XML Naming Conventions? -- <%= Clinton Gallagher, "Twice the Results -- Half the Cost" Architectural & e-Business Consulting -- Software Development NET...
18
3290
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
2293
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 behind going for a different convention in .NET. The recommendations do make sense (to me, at least but I may be wrong and would like someone to correct me). Scope Prefixes Member Variable Prefix: Most of the people still use (and like the idea...
5
2560
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. Java style Class MyClass { int someValue;
0
9642
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10774
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10489
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9314
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7746
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5617
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5780
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4411
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3076
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.