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

Home Posts Topics Members FAQ

ISO Studies of underscores vs MixedCase in Ada or C++

I am in search of any rigourous,
scientific, academic or industrial studies
comparing naming conventions in
C++ or similar languages such as
Ada:

Specifically, are names formed with
underscores more or less readable
than names formed with MixedCase
StudlyCaps camelCase?

....and similarly, any measurements
of programmer productivity, bug rate,
etc.; although IMHO readability matters
most.
* Religion - NOT?!

I understand that this is a religious issue
for many programmers, an issue of programming style.
I am not interested in a religious war.
I obviously have my own opinion, but I am
open to scientific evidence.
* Ada Studies?

I thought that I had seen studies like
this in some of the early design documents
for Ada, but I have not been able to find
such references on the web. Which is not
entirely surprising, since Ada was designed
prior to the web.

The Ada 83 and 95 Quality Guidelines recommend
underscores to improve readability, but provide
no source justifying this statement.
* What such studies might look like

Simple readability and recall:
- present a test subject with
a list of compound words
formed with underscoresand mixed case
- remove the list, and ask test subject
to write it
- score on accuracy

Program debugging
- present programs that are otherwise identical,
differing only in their use of underscores/MixedCase
to test subject programmers (e.g. a CS class)
- program has a known bug
- ask test subjects to find bug
- score on accuracy locating bug

Cruel TA study:
- Two sections of a CS class
- Enforce programming standards,
underscores vs MixedCase
- Pose a programming problem
- Score according to success
completing assignment

Empirical:
- Given version control databases
of large programs, some written in underscore
style, others in MixedCase
- Total bug rates normalized by LOC, name count, etc.
- OR: count only bugs that can be attributed
(after inspection of checkins) to misnamed variables

For that matter, I would be interested in any surveys
folks may have done that count projects and their
coding standards, possibly weighted
- open source (e.g. sourceforge)
- industrial
- textbooks, weighted by sales
- websites of coding standards, weighted by Google score...
Although this is less convincing than a rigorous study.
* Explanation of Newsgroups Chosen

I hope it is obvious why I have chosen these
newsgroups to post this search to:

comp.software-eng, comp.programmin g,
- an issue of software engineering
comp.lang.c++,
- the language I am most interested in
comp.lang.ada
- because I vaguely recall historical work
Jul 19 '05
84 5952
"Peter Bushell" <DE************ ****@software-inCAPStegrity.c om> wrote:
"Jakob Bieling" <ne*****@gmy.ne t> wrote:
"Jacob Sparre Andersen" <sp****@crs4.it > wrote: Also, sometimes I tend to abbreviate quite a lot, so that later I

might
not know what it stands for. In cases like those I just put a comment next to where I declared the variable and I can keep saving those keystrokes.

If you can't remember what it meant, pity the poor engineer who has to
maintain your code when you've gone! Having to look up a declaration every
few seconds is not acceptable.
You do not have to. All declarations (loop counters etc. are an
exception) are at the beginning of the function, along with possible
comments. And for those identifiers where comments are necessary, I do not
think it is impossible to remember them.
There is evidence* to suggest that 80% of programming is (or should be)
thinking time. Saving keystrokes is therefore not an issue.


True, but it is still pretty annoying to type all kinds of variable
names out (we are talking about long names, anything over 10 letters,
right?) all the time you use them. The 'burden' of remembering 5 or 6 names
for which you always see the abbreviations is less, in my opinion.

To avoid misunderstandin gs, I do not approve using abbreviations for all
kinds of variables. But I do find it acceptable to use my way of
abbreviating (including comments) for function local variables.

hth
--
jb

(replace y with x if you want to reply by e-mail)
Jul 19 '05 #71
On Tue, 14 Oct 2003 18:46:59 +0200, "Jakob Bieling" <ne*****@gmy.ne t>
wrote:
True, but it is still pretty annoying to type all kinds of variable
names out (we are talking about long names, anything over 10 letters,
right?) all the time you use them


A good editor can eliminate that problem.

--
Al Balmer
Balmer Consulting
re************* ***********@att .net
Jul 19 '05 #72
"Jakob Bieling" <ne*****@gmy.ne t> wrote:
Not sure where I picked that habit up, but I guess it is pure laziness.
I could not imagine having to type those long names everytime you use them.


Neither can I. I rarely abbreviate in a variable name. But I rely on code
completion in my editor to save typing those keystrokes.

The problem is that once you start abbreviating, odds are some abbreviations
are not going to be consistent. I've seen nbr, no, nu, or num instead of
number. Using an editor that will complete nu to number might make your
life easier in a multi-person project.

That said, I'll use cachedUrl over the non-abbreviated form, but that's
because I expect most people to abbreviate URL the same way.
Jul 19 '05 #73
"Alan Balmer" <al******@att.n et> wrote in message
news:hs******** *************** *********@4ax.c om...
On Tue, 14 Oct 2003 18:46:59 +0200, "Jakob Bieling" <ne*****@gmy.ne t>
wrote:
True, but it is still pretty annoying to type all kinds of variable
names out (we are talking about long names, anything over 10 letters,
right?) all the time you use them


A good editor can eliminate that problem.

For function local variables, mine does not. For class members or
identifiers in a namespace it does.

regards
--
jb

(replace y with x if you want to reply by e-mail)
Jul 19 '05 #74
<br*******@yaho o.com> wrote in message
news:h5******** *************** *********@4ax.c om...
"Jakob Bieling" <ne*****@gmy.ne t> wrote:
Not sure where I picked that habit up, but I guess it is pure laziness.
I could not imagine having to type those long names everytime you use
them.
Neither can I. I rarely abbreviate in a variable name. But I rely on code completion in my editor to save typing those keystrokes.
As a said in the other post: For function local variables, mine does not
have that feature.
The problem is that once you start abbreviating, odds are some abbreviations are not going to be consistent. I've seen nbr, no, nu, or num instead of
number. Using an editor that will complete nu to number might make your
life easier in a multi-person project.


Yes, I do write 'num' instead of number. Or I also write 'msg' instead
of message, or 'ips' for an 'InterProcessSy nchronisation' handle. In case of
ips, I might not know what it is without context. But when seeing that
variable used in a function call, it is clear what it is supposed to be.
Along with the comments in the code, I find it justified and not overly hard
to read.

regards
--
jb

(replace y with x if you want to reply by e-mail)
Jul 19 '05 #75
On Wed, 15 Oct 2003 07:34:33 +0200, "Jakob Bieling" <ne*****@gmy.ne t>
wrote:
"Alan Balmer" <al******@att.n et> wrote in message
news:hs******* *************** **********@4ax. com...
On Tue, 14 Oct 2003 18:46:59 +0200, "Jakob Bieling" <ne*****@gmy.ne t>
wrote:
> True, but it is still pretty annoying to type all kinds of variable
>names out (we are talking about long names, anything over 10 letters,
>right?) all the time you use them


A good editor can eliminate that problem.

For function local variables, mine does not. For class members or
identifiers in a namespace it does.

Mine will complete any symbol it knows about, or give you a drop-down
list if there's more than one choice. However, almost any editor will
allow you to code with abbreviations, then expand them to full names
with search and replace. This can be useful for some people who have
total recall in the heat of a programming session, but can't remember
what they were thinking a week later :-)

--
Al Balmer
Balmer Consulting
re************* ***********@att .net
Jul 19 '05 #76
"Jakob Bieling" <ne*****@gmy.ne t> writes:
"Alan Balmer" <al******@att.n et> wrote in message
news:hs******** *************** *********@4ax.c om...
On Tue, 14 Oct 2003 18:46:59 +0200, "Jakob Bieling" <ne*****@gmy.ne t>
wrote:
True, but it is still pretty annoying to type all kinds of variable
names out (we are talking about long names, anything over 10 letters,
right?) all the time you use them


A good editor can eliminate that problem.

For function local variables, mine does not. For class members or
identifiers in a namespace it does.


But why would you want to make function local variables' names more than
10 letters long?
My local variable names tend to consist of only one word, e.g

OutputStreamWri ter writer;

Or are your functions so long that you need longer variable names?

regards
frank

--
Frank Schmitt
4SC AG phone: +49 89 700763-0
e-mail: frankNO DOT SPAMschmitt AT 4sc DOT com
Jul 19 '05 #77
James Dow Allen wrote:
CamelMode, camel_mode, etc. are all quite *readable*;
It may be a matter of personal taste (haven't seen any actual studies),
but I prefer underscores between words, when I am no allowed to put
spaces there. In Ada I follow the style guide and use both underscores
and capitalisation.
when using long
names the important thing is to make them *writable*,
Try to count how often you _read_ and _write_ an identifier. I think
you might be surprised by the difference. Easy writing of the
identifers is not anywhere nearly as important as easy reading.
Consistency is therefore the important thing.
It is.
If you abbreviate words,
abbreviate them as the first 4 (or whatever) letters, consistently.
I prefer the suggestion from the Ada style guide (IIRC) that you don't
abbreviate words, and that you only use acronyms from a limited
project-specific list.
(I usually rewind a file with "lseek(fd, 0L, 0)" because I can't
remember if 0 is SEEKSET or SEEK_SET.)


Very annoying with a standard library with an inconsistent naming of
identifiers.

One more point on the topic of consistent naming of identifiers. I find
the style with using different naming conventions for functions,
constants, variables, etc. very annoying. I _don't_ want to have to
worry if something is a function, constant or variable. Specially not
if it actually is an implementation dependent detail. So _please_ use
the same naming convention for all identifiers.

Jacob
--
"Any, sufficiently complicated, experiment is indistinguishab le from
magic."

Jul 19 '05 #78
Jakob Bieling wrote:
True, but it is still pretty annoying to type all kinds of variable
names out
I suppose I should thank my mother for insisting that I learned how to
use a typewriter.
To avoid misunderstandin gs, I do not approve using abbreviations for all
kinds of variables. But I do find it acceptable to use my way of
abbreviating (including comments) for function local variables.


Do non-local variables really exist? :-)

But yes, if you make sure that the declaration of the variables is
always immediately visible, when one is observing their use, then I can
understand your argument (although I still don't approve of it).

Jacob
--
"The current state of knowledge can be summarised thus:
In the beginning, there was nothing, which exploded."

Jul 19 '05 #79
Jakob Bieling wrote:

[ abbreviated identifier prefixes ]
Not sure where I picked that habit up, but I guess it is pure laziness.
I could not imagine having to type those long names everytime you use them.
Well. I tend to read code more often than I write it (even my own), and
most of my time is spent thinking about what to write, so saving a few
keystrokes really doesn't make sense to me.
Especially counter variables in for-loops (posting from comp.lang.c++) ..
you also use simple i's and j's etc. there, right?
No. (unless it is for matrix and tensor manipulation, where the
"documentat ion" actually says "i", "j" and "k")
As you seem to be posting from comp.lang.ada,
Well. There and "comp.softw are-eng".
I am not too sure if Ada provides such constructs in the
same way C++ does, so maybe Ada has different means of looping in a
for-loop-kind-of-way (yes, I know pretty much nothing about Ada).
The Ada for loop is not as flexible/error-prone as I remember the C++
for loop (which I haven't had to use for years :). A quick example:

for Day in Monday .. Friday loop
Put (Day); Put_Line (" is a workday.");
end loop;

(where I assume I have declared an enumerated type based on the days of
the week). The counter variable is created by the for loop statement,
so you don't have to worry about making an explicit declaration of a
variable for use as the counter. I seem to remember that you have to
have an explicit declaration of the counter variable in C++, which of
course makes a slight difference.
Also, sometimes I tend to abbreviate quite a lot, so that later I might
not know what it stands for.
Not good. That costs time and is a potential source for errors if you
misremember the meaning of the abbreviation.
In cases like those I just put a comment next
to where I declared the variable and I can keep saving those keystrokes.


I consider that a misuse of comments. I see comments as a means for
expressing what _can_ not be expressed in actual code. Otherwise you
risk ending up with code and comments that say different things. One
result of this view is of course that it differs from language to
language, what are reasonable comments.

My main worry with long identifier names is that they shouldn't make the
lines so long that they become incomprehensibl e.

Jacob
--
"There are only two types of data:
Data which has been backed up
Data which has not been lost - yet"

Jul 19 '05 #80

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

Similar topics

6
1914
by: Geoff Turner | last post by:
Using VB6, I set up a menu like &File ....&Open ....&Close etc. In design mode, the F is underscored as expected but O and C are not. In run mode no underscores are displayed when selecting menu items with the mouse.
31
2940
by: Chris S. | last post by:
Is there a purpose for using trailing and leading double underscores for built-in method names? My impression was that underscores are supposed to imply some sort of pseudo-privatization, but would using myclass.len() instead of myclass.__len__() really cause Python considerable harm? As much as I adore Python, I have to admit, I find this to be one of the language's most "unPythonic" features and a key arguing point against Python. I've...
20
4208
by: benhoyt | last post by:
Hi guys, I've been using Python for some time now, and am very impressed with its lack of red tape and its clean syntax -- both probably due to the BDFL's ability to know when to say "no". Most of the things that "got me" initially have been addressed in recent versions of Python, or are being addressed in Python 3000. But it looks like the double underscores are staying as is. This is probably a good thing unless there are better...
0
9480
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
10330
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...
1
10093
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
9952
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
8976
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
6740
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
5381
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...
1
4053
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
2880
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.