473,785 Members | 2,994 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
an*******@amd.c om (Andy Glew) wrote in message news:<2c******* *************** ****@posting.go ogle.com>...
I am in search of any rigourous,
scientific, academic or industrial studies
comparing naming conventions in
C++ or similar languages such as
Ada:
- SNIP -
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


Maybe the "Psychology of Programming Interest Group" mailing list
would be a good place to ask?
http://www.ppig.org/lists.html
Jul 19 '05 #61
Peter Ammon wrote:
classmethod :
access_specifie r
method_type_spe cifier
method_return_t ype_specifier
method_declarat ion
method_body
You've piqued my interest, since I'm the first to admit that my
grammar specifications are hard to read.

Where do you put the action in the above code?

classmethod :
access_specifie r
method_type_spe cifier
method_return_t ype_specifier
method_declarat ion
method_body
{ doSomething(); }


I thought this was a grammar definition? I'd have thought that

method_body :== { doSomething(); }

But if they are different, the way you did it seems fine to me.
What if there's more than one reduction possible?

classmethod :
access_specifie r
method_type_spe cifier
method_return_t ype_specifier
method_declarat ion
method_body
{ doSomething(); }
| something_else
another_thing
even_more
blah_blah
{ doSomethingElse (); }


Probably break them up in some fashion:

class-method:
class-method-normal |
class-method-extended

class-method-normal:
access-specifier
method-type-specifier
method-return-type-specifier
method-declaration
method-body

class-method-extended:
something-else
another-thing
even-more
blah-blah

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


Others have already mentioned Lisp, so I don't have to!
(Well,... *didn't* have to... :-)

--
|_ CJSonnack <Ch***@Sonnack. com> _____________| How's my programming? |
|_ http://www.Sonnack.com/ _______________ ____| Call: 1-800-DEV-NULL |
|______________ _______________ _______________ _|_____________ __________|
Jul 19 '05 #62
> takeAction(doYo uMind.ifI(openT heWindow));

take_action (do_you_mind.if _i (open_the_windo w));

take_Action (do_You_Mind.if _I(open_The_Win dow));

Take_Action (Do_You_Mind.If _I (Open_The_Windo w));


Once you start looking at the readability whole expressions, you also need
to look at the use of spaces. The above are not consistant about if a space
is used with round brackets. [And then there is the question - is it more
readable with the space outside or inside the bracket - my preference is for
inside - so the opening bracket is with the function name rather than the
first parameter.]
Take_Action (Do_You_Mind.If _I (Open_The_Windo w));
Take_Action(Do_ You_Mind.If_I(O pen_The_Window) );
Take_Action( Do_You_Mind.If_ I( Open_The_Window ) );

To go back to the original question - there have been studies that showed
underscores gave the most readable results - unfortunately I have lost the
reference and I would also like to get my hands on it again.

-
Stephen Baynes CEng MBCS
My views are my own

"Georg Bauhaus" <ge***@strudel. futureapps.de> wrote in message
news:86******** ****@strudel.fu tureapps.de...
Jul 19 '05 #63
"Jacob Sparre Andersen" <sp****@crs4.it > wrote in message
news:3F******** ******@crs4.it. ..
Jakob Bieling wrote:
"Leif Roar Moldskred" <rm******@onlin e.no> wrote in message
news:86******** ****@huldreheim .huldreskog.no. ..
"Jakob Bieling" <ne*****@gmy.ne t> writes:
Ah, I did not consider this difference even. *g* My point was,

checking my own identifier names for spelling errors based on natural language rules is a bad idea.


Why. They are hopefully spelled correctly. Otherwise you are adding an
unneeded complication to reading and understanding your code.
Instead, a special code-spell-checker would be great:

a/ 'Created' identifiers are automatically added to the list of known words (for the current compilation run only)


I wouldn't like that. Incorrectly spelled identifiers make code
maintenance more difficult.


I do not know how you choose your identifier names, but I usually give
them abbreviated prefixes, which would make every spell-checker flag a
misspelling. See Kevin's example (news:3f******* *@nntp2.nac.net )
b/ When an identifier is used, but not found, the spell-checker tries to find out what I meant (like any spell-checker)


Would certainly be nice. But doing a proper job here basically means
trying to compile the code. If you decide to ignore visibility rules,
things will of course become much simpler.


Right. You got me thinking here, though. Since the code is
sort-of-spell-checked by the compiler already, point a and b are pretty much
superflous (unless you want the luxury of the compiler trying to guess the
correctly spelled identifier name). No need for a special spell-checker
anymore, except that it should only spell-check comments ;)

regards
--
jb

(replace y with x if you want to reply by e-mail)
Jul 19 '05 #64
"Jakob Bieling" <ne*****@gmy.ne t> wrote in message
news:bm******** *****@news.t-online.com...
correctly spelled identifier name). No need for a special spell-checker
anymore, except that it should only spell-check comments ;)


I often refer to identifier names in my comments,
so back to the original problem. :-)

-Mike
Jul 19 '05 #65
In comp.lang.ada Stephen Baynes. <st************ @soton.sc.phili ps.com> wrote:
: Once you start looking at the readability whole expressions, you also need
: to look at the use of spaces. The above are not consistant about if a space
: is used with round brackets.

Glad someone noticed, explicitly :-) Has anybody written Algol
programs (using spaces in identifiers)?
Georg
Jul 19 '05 #66
Jakob Bieling wrote:
"Jacob Sparre Andersen" <sp****@crs4.it > wrote in message
news:3F******** ******@crs4.it. ..

I wouldn't like that. Incorrectly spelled identifiers make code
maintenance more difficult.


I do not know how you choose your identifier names, but I usually give
them abbreviated prefixes,


I practically never use abbreviations or acronyms in identifiers -
except for those from the project specific "approved" list ("IO" is
always there, though :). And when I do, it is always as separate parts
like in "Integer_Text_I O". I would never write "IntegerTextIO" ,
"intTextIO" or "Int_Text_I O" in my code.

If you want more details on how I choose my identifier names, then
chapter 3 in »Ada Quality and Style« is hopefully a good description.

Greetings,

Jacob
--
There only exist 10 kinds of people: Those who know binary
numbers and those who don't know binary numbers.

Jul 19 '05 #67
"Jacob Sparre Andersen" <sp****@crs4.it > wrote in message
news:3F******** ******@crs4.it. ..
Jakob Bieling wrote:
"Jacob Sparre Andersen" <sp****@crs4.it > wrote:
I wouldn't like that. Incorrectly spelled identifiers make code
maintenance more difficult.
I do not know how you choose your identifier names, but I usually give them abbreviated prefixes,

I practically never use abbreviations or acronyms in identifiers -

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.
Especially counter variables in for-loops (posting from comp.lang.c++) ..
you also use simple i's and j's etc. there, right? As you seem to be posting
from comp.lang.ada, 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).

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.

regards
--
jb

(replace y with x if you want to reply by e-mail)
Jul 19 '05 #68
"Mike Wahler" <mk******@mkwah ler.net> wrote in message
news:2z******** *********@newsr ead4.news.pas.e arthlink.net...
"Jakob Bieling" <ne*****@gmy.ne t> wrote in message
news:bm******** *****@news.t-online.com...
correctly spelled identifier name). No need for a special spell-checker
anymore, except that it should only spell-check comments ;)


I often refer to identifier names in my comments,
so back to the original problem. :-)

Ok, so we do need a scope-less list of identifier names :p
--
jb

(replace y with x if you want to reply by e-mail)
Jul 19 '05 #69

"Jakob Bieling" <ne*****@gmy.ne t> wrote in message
news:bm******** *****@news.t-online.com...
"Jacob Sparre Andersen" <sp****@crs4.it > wrote in message
news:3F******** ******@crs4.it. ..

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.

There is evidence* to suggest that 80% of programming is (or should be)
thinking time. Saving keystrokes is therefore not an issue.

Regards,

Peter Bushell.

* My source was Glass, Robert L., "Facts and Fallacies of Software
Engineering". His source was some research material published in another of
his books: "Software Creativity".
Jul 19 '05 #70

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
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
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...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
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
2
3654
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
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.