473,803 Members | 2,599 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 1791
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
2485
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
6551
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
2277
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
7149
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
4353
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
3289
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
2292
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
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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
10309
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...
1
10289
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10068
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9119
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
7600
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
6840
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5496
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...

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.