473,704 Members | 6,472 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2479
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**********@bt internet.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**********@bt internet.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#G uidelines>.

--
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**********@bt internet.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********@yah oo.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.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**********@bt internet.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**********@Ho me.com
Jul 23 '05 #8

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

Similar topics

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.
1
6541
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...
4
7145
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
4345
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...
5
6165
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 wonder if I can use the same naming conventions as for VB6 ? If so, what about the names for the new objects in .NET. Kind regards rastaman
4
5447
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 in vain. I'd much appreciate it if someone could guide me with regards to this. All i need are standards for me to follow by my self. Cuz i'm finding it difficult to make my own darn standards.
9
3808
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 input for Window.Form controls and what they are using for naming controls.
35
12186
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 recommended practise? Thanks.
1
801
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 "naming conventions" in the groups. In my oppinion one of the good conventions is presented by Joe Celko in "SQL Programming Style". I would suggest reading it and pick up
0
8763
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
8676
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
9266
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
9127
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
9020
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
8972
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
7878
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...
0
4435
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...
3
2073
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.