473,796 Members | 2,690 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 5960
Wes Groleau wrote:
Peter Ammon wrote:
Agreed! I wish that more languages allowed hyphen use in identifiers.
Dylan is the only one I can think of off the top of my head.

Does Dylan prevent having variables named Max,
Max-Iterations, & Iterations in the same scope?


No. Whitespace is more important in Dylan than in a language like C.

Max-Iterations <-- variable name
Max - Iterations <-- Max minus Iterations

Other strange characters can appear in Dylan variable names. This
allows for some nice naming conventions without the nastiness of
something like Hungarian Notation. See
http://www.gwydiondylan.org/gdref/tu...nventions.html

-Peter

Jul 19 '05 #41
If you happen to be use GNAT (GNU Ada), the compiler does do some degree of
spell checking.

gcc -c dointxor.adb
dointxor.adb:30 :28: "b_valu" is undefined
dointxor.adb:30 :28: possible misspelling of "b_value"
gnatmake: "dointxor.a db" compilation error

If you use the GPS for programming Ada, you'll get a little wrench icon next
to the error in the output window. If you click on the wrench it corrects
the spelling error.

If you're really interested in having comments spell checked, the folks at
ACT (Ada Core Techologies) would probably add the feature for a fee.

Steve
(The Duck)
"Leif Roar Moldskred" <rm******@onlin e.no> wrote in message
news:86******** *******@huldreh eim.huldreskog. no...
[snip]

This touches on one of my pet annoyances with development tools today:
no way to easily spell-check your code. In my opinion, a development
environment should at the very _least_ let you easily spell-check all
the text in comments, and preferably the individual words in variable
and function names (whether the words are separated by mixed case,
hyphens or underscores.)

Unfortunately, nobody else seems to mind. *sighs* Oh well,
spell-checkers are overrated anyway.

--
Leif Roar Moldskred

Jul 19 '05 #42
James Dow Allen wrote:
(I usually rewind a file with "lseek(fd, 0L, 0)" because I can't
remember if 0 is SEEKSET or SEEK_SET.)


The Vim editor is cool for things like this because you can add your
own words to the syntax highlighting. I write Windows programs and
I have over a hundred typedef's and constants in my word list.
Actually, Vim's C syntax file comes with the standard C constants
and typedef's highlighted.

Jul 19 '05 #43
Peter Ammon wrote:
Programmer Dude wrote:
Or my preference if the tool allows

classmethod :
access-specifier
method-type-specifier
method-return-type-specifier
method-declaration
method-body

(In proportional fonts, hyphens are usually skinnier than
underscores and (to my eye) make the text more readable.
It's not as noticable with monospace fonts, but I think the
lower example looks better (read: more readable :-).)

Agreed! I wish that more languages allowed hyphen use in identifiers.
Dylan is the only one I can think of off the top of my head.


Lisp and Scheme.

Jul 19 '05 #44
"Steve" <no************ *@comcast.net> writes:
If you happen to be use GNAT (GNU Ada), the compiler does do some degree of
spell checking.

gcc -c dointxor.adb
dointxor.adb:30 :28: "b_valu" is undefined
dointxor.adb:30 :28: possible misspelling of "b_value"
gnatmake: "dointxor.a db" compilation error


That's not really spell-checking though - it doesn't check "b_value" to see
if "value" is a proper word in English.

--
Leif Roar Moldskred
Jul 19 '05 #45
"Kevin Morenski" <km@nospam.geek center.net> writes:
Let's say you had a variable named "tHTa," for example. With respect to
your concept, this would be a misspelling of the word "that." Now, a lot of
programmers--myself included--use letters to represent certain things in
variable names. tHTa could mean "type HTa" or anything else a programmer
could think of. How could a program possibly differentiate between
conventions in the naming of variables?


In the same way that spell-checkers for ordinary text today handles names and
other words that are correct, but not in the dictionary: When detecting the
unknown word the first time, ask the user what to do with it - whether to
correct it, accept this instance, accept all instances in this document or
add it to your private dictionary. (For a spell-checking of source-code we'd
probably also want the option "accept all instances with this case.")

This really isn't any different from the same problem in regular text,
except that your programming convention might cause a lot of unknown
words to appear. If that's a major headache, just don't spell-check.

--
Leif Roar Moldskred
Jul 19 '05 #46
"Matt Gregory" <bl************ ****@earthlink. net> wrote in message
news:BPvfb.2044 5
Agreed! I wish that more languages allowed hyphen use in identifiers.
Dylan is the only one I can think of off the top of my head.


Lisp and Scheme.


COBOL
Jul 19 '05 #47
"Leif Roar Moldskred" <rm******@onlin e.no> wrote in message
news:86******** ****@huldreheim .huldreskog.no. ..
"Steve" <no************ *@comcast.net> writes:
If you happen to be use GNAT (GNU Ada), the compiler does do some degree of spell checking.

gcc -c dointxor.adb
dointxor.adb:30 :28: "b_valu" is undefined
dointxor.adb:30 :28: possible misspelling of "b_value"
gnatmake: "dointxor.a db" compilation error
That's not really spell-checking though - it doesn't check "b_value" to

see if "value" is a proper word in English.

But it is that kind of word-matching I would personally like to see in
more compilers (specifically C++ compilers).

I do agree with Kevin Morenski (news:3f******* *@nntp2.nac.net ) that a
real spell-checker for source code is not practicable. You said that the
spell-checker would just have to ask you whether to ignore it or how else to
proceed. Have you thought about how annoying 100s or even 1000s of those
messages boxes, asking how to proceed, will be when compiling already
existing source with this spell-checker?

regards
--
jb

(replace y with x if you want to reply by e-mail)
Jul 19 '05 #48
Martin Dowie wrote:
"Matt Gregory" <bl************ ****@earthlink. net> wrote in message
news:BPvfb.2044 5
Agreed! I wish that more languages allowed hyphen use in identifiers.
Dylan is the only one I can think of off the top of my head.


Lisp and Scheme.


COBOL


Isn't there a variation of Godwin's Law covering COBOL? :>

--
Corey Murtagh
The Electric Monk
"Quidquid latine dictum sit, altum viditur!"

Jul 19 '05 #49
Matt Gregory wrote:
Peter Ammon wrote:
Programmer Dude wrote:
.... snip ...

(In proportional fonts, hyphens are usually skinnier than
underscores and (to my eye) make the text more readable.
It's not as noticable with monospace fonts, but I think the
lower example looks better (read: more readable :-).)


Agreed! I wish that more languages allowed hyphen use in identifiers.
Dylan is the only one I can think of off the top of my head.


Lisp and Scheme.


Cobol

--
Chuck F (cb********@yah oo.com) (cb********@wor ldnet.att.net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home .att.net> USE worldnet address!
Jul 19 '05 #50

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

Similar topics

6
1915
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
2943
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
10453
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
10172
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
10003
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
9050
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
6785
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
5573
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4115
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
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2924
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.