473,322 Members | 1,671 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,322 software developers and data experts.

Naming Conventions

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.

I searched the groups also and found lots of (lengthy) discussions on
the topic and all i want really is just to read a few guidelines to get
some ideas, pick the ones I like and use that. I've looked around in
books like C++ Coding Standards (Sutter), Effective C++ (Meyers) but
they talk about coding practices rather than naming.

Caroline Middlebrook

Jul 23 '05 #1
7 2432
ben
Try to read about Code Complete by Steve McConnell

ben
Jul 23 '05 #2
Hi,

Often the naming convention( part of Coding standards) are formed
locally by oraganisations(Software companies & Universities). Sometimes
these standards are influenced by Software Configuration Management
(SCM) system of the organisation.

-vs_p...

Jul 23 '05 #3
cm**********@btinternet.com wrote:
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.


I recommend the book "The elements of C++ style".
Jul 23 '05 #4
* cm**********@btinternet.com:

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.
Good.

Generally you'll have to accept the fact that libraries employ
different conventions, which means some inconsistency no matter what.

However, one common convention is illustrated by the standard C++
library, and another one is the Java convention (exception: Java uses
all uppercase for constants, as a convention inherited from early C,
but that C/C++ convention has always been for macros, _not_ for constants
except where they're expressed as macros).

I searched the groups also and found lots of (lengthy) discussions on
the topic and all i want really is just to read a few guidelines to get
some ideas, pick the ones I like and use that. I've looked around in
books like C++ Coding Standards (Sutter), Effective C++ (Meyers) but
they talk about coding practices rather than naming.


Make what's important to you visually obvious, and all the rest the same.

Personally I prefer to use PascalCase for class names, a "my" prefix for
members (except sometimes boolean members), and a trailing underscore for
templates, with all the rest -- except macros -- in camelCase.

Boost, in contrast, is very template-oriented, almost all templates, and
therefore the Boost naming guidelines reflect that:
<url: http://www.boost.org/more/lib_guide.htm#Guidelines>.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 23 '05 #5
cm**********@btinternet.com wrote:
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.
Yes, there are lots of them.
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.

I searched the groups also and found lots of (lengthy) discussions on
the topic and all i want really is just to read a few guidelines to get
some ideas, pick the ones I like and use that. I've looked around in
books like C++ Coding Standards (Sutter), Effective C++ (Meyers) but
they talk about coding practices rather than naming.


Well, by asking such a question, you open a can of worms. Since many aspects
of coding conventions are more a matter of taste than based on facts,
discussions about them often result in holy wars, which is what you are
referring to as "(lengthy) discussions". If you ask 5 people, you might get
8 opinions, or none at all.
I think the exact conventions are not really important. The only important
thing is to be consistent within one project. This might be a bit
problematic if you use external libraries in your program, and those
libraries use different conventions. OTOH, I often tend to encapsulate such
library code behind my own classes.
If you are using external libraries, it might be a good idea to stick to the
naming conventions of the one you're using the most.

Jul 23 '05 #6
ben
And sometimes by the style employed by the library you use. Really messing
up when libraries of different coding styles are used in one project.

"Achintya" <vs********@yahoo.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Hi,

Often the naming convention( part of Coding standards) are formed
locally by oraganisations(Software companies & Universities). Sometimes
these standards are influenced by Software Configuration Management
(SCM) system of the organisation.

-vs_p...

Jul 23 '05 #7
On 10 May 2005 01:34:51 -0700, cm**********@btinternet.com wrote:
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.

I searched the groups also and found lots of (lengthy) discussions on
the topic and all i want really is just to read a few guidelines to get
some ideas, pick the ones I like and use that. I've looked around in
books like C++ Coding Standards (Sutter), Effective C++ (Meyers) but
they talk about coding practices rather than naming.

Caroline Middlebrook


What everyone else said. Except for leading underscores, which are a
no-no, it's probably a toss-up in the end.

Leading underscores are to be avoided in user code. These are reserved
for names used in the standard libraries or built-in names defined by
the compiler or its other libraries ("reserved for the implementation"
is how it is worded in the standard).

The company I used to work for had lots of code where private member
variables were always written with leading underscores because the
company's previous coding guidelines said to do so. Wow, that was a
job when we realized that we should change it ... we went in and
tacked an "m" on in front of the leading underscore because it
amounted to the least amount of typing and still conveyed the
necessary information ("m_" for member).

I don't like trailing underscores either because they are often
overlooked in the implementation code. They have a tendency to get
confused with local variables spelled the same except for the trailing
underscore.

--
Bob Hairgrove
No**********@Home.com
Jul 23 '05 #8

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...
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...
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...
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...
4
by: Patrick | last post by:
what are the general naming conventions for vb.net controls. esp txtUserName, lblPassword, btnSubmit What are the prefixes for the controls???? I've tried to search hi and low on the net, but...
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.