473,796 Members | 2,525 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
>>>>> "Martin" == Martin Dowie <ma**********@b topenworld.com> writes:

: "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

Also a few languages, like SNOBOL4, that allow you to have
any string as a variable name,

$'The Shoemaker - page 3' = 'Once upon a time'

ML allows minus {minus} as identifiers, and also ":->" and the like,
though not ":-)".
Georg
Jul 19 '05 #51
"Jakob Bieling" <ne*****@gmy.ne t> writes:
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?


Oh, I wouldn't want it to be part of the compiler, or continiously on. Rather,
I'd just want to be able to run a command in my editor to spell-check the
source-code I'm currently working on - much like I today invoke ispell in
emacs for regular text files.

--
Leif Roar Moldskred
Jul 19 '05 #52
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 best choice for rewinding a stdio file stream is rewind().


Brian Rodenborn
Jul 19 '05 #53
"Leif Roar Moldskred" <rm******@onlin e.no> wrote in message
news:86******** ****@huldreheim .huldreskog.no. ..
"Jakob Bieling" <ne*****@gmy.ne t> writes:
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?
Oh, I wouldn't want it to be part of the compiler, or continiously on.

Rather, I'd just want to be able to run a command in my editor to spell-check the
source-code I'm currently working on - much like I today invoke ispell in
emacs for regular text files.

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. 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)
b/ When an identifier is used, but not found, the spell-checker tries to
find out what I meant (like any spell-checker)
c/ Comments are spell-checked like in any other word processor, except
that identifier names should also be considered

So let us assume we have this (rather useless) piece of C++ code:

1 int main ()
2 {
3 char* pRok = new char;
4 *pork = 'p';
5 delete pRok; // do not forget t delete pRok!
6 }

In line 3, the spell-checker should not question the identifier name and
try to tell me that I meant 'pork' (see a/ above). Instead, it should tell
me in line 4 that I most probably meant 'pRok' and not 'pork' (see b/
above). And last but not least, in line 5, the spell-checker should point
out the missing 'o' (ie. ".. forget to ..") but leave 'pRok' undiagnosed.

regards
--
jb

(replace y with x if you want to reply by e-mail)
Jul 19 '05 #54
"Default User" <fi********@com pany.com> wrote in message
news:3F******** *******@company .com...
The best choice for rewinding a stdio file stream is rewind().


Nah, rewind() makes me think of tapes, and that makes me feel old.
Jul 19 '05 #55
Georg Bauhaus wrote:
>> "Martin" == Martin Dowie <ma**********@b topenworld.com> writes:


: "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

Also a few languages, like SNOBOL4, that allow you to have
any string as a variable name,

$'The Shoemaker - page 3' = 'Once upon a time'


You can do the same thing in Perl:

${'The Shoemaker - page 3'} = 'Once upon a time';

And since perl interpolates in double quoted strings you can include any
8 bit value:

${"\xFF\0\t\cV" } = 'Once upon a time';
John
--
use Perl;
program
fulfillment
Jul 19 '05 #56
"Jim Rogers" <ji************ **@worldnet.att .net> wrote in message
news:82******** *************** ***@posting.goo gle.com...
"William" <Re***@NewsGrou p.Please> wrote in message

news:<ud******* *************@g iganews.com>...
Talking to myself here... I occurred to me that its syntax highlighting
makes spell checking reserved words less necessary - and the syntax
highlighting can deal with case. -Wm


Even more to the point -- any compiler should be
able to properly recognize reserved words.
Why use another tool to check what the compiler will also check?


Until we got faster machines, one of our builds could take an hour.
No fun to have the compiler detect a mispelled word 50 minutes in.
(Sure, if everyone did an incremental test build, the problem would
be avoided, but...) -Wm
Jul 19 '05 #57
"Leif Roar Moldskred" <rm******@onlin e.no> wrote in message
news:86******** ****@huldreheim .huldreskog.no. ..

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.")


Well, they will if you add the entire label to the dictionary, but none I'm
aware
of will break up words based on mixed-case. Ultraedit will break up words
on underscores - didn't know that until I just tried it I can make it ignore
mixed-case words, but not break them apart. (It does support multiple user
dictionaries, so you could have a dictionary-per-project defining all the
approved labels.) -Wm

Jul 19 '05 #58
On Fri, 03 Oct 2003 15:42:20 -0700, Peter Ammon
<pe*********@ro cketmail.com> wrote:
<snip>
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.

COBOL ! Only embedded, though. My compiler accepts -X as minus X with
a warning, but I don't think that's standard.

Also the usual suspects: FORTH allows everything but space (and
controls); and LISP everything but space, parens, period, quote,
backquote, and undoubled slash, if I haven't forgotten anything.

- David.Thompson1 at worldnet.att.ne t
Jul 19 '05 #59

"Kevin Morenski" <km@nospam.geek center.net> schrieb im Newsbeitrag
news:3f******** @nntp2.nac.net. ..
// Number of misspelled words fuond so far
int noErorsInTetx = 0;

I want to spell-check this such that I get notified both on "fuond"
for "found", "Erors" for "Errors" and "Tetx" for "Text". They are all,
after all, words in natural language, and it should be possible to
spell-check them automatically.
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?

It's much simpler to check the spelling of comments...prog rammers have
developed so many conventions for making their lives easier; a spell checker on variable names just adds one more problem to overcome.


An editor which is capable of finding the definition of variables and
highlighting a name already defined/declared might solve that problem. VB
has that feature to a certain degree - if you use mixed case for names of
variables, functions etc. and you type a name already declared in lowercase
the editor will automatically convert it to the form in which it is
declared. If you know, the name is declared and case does not flip you know
you made a typo. IIRC Keil development system for embedded C programming has
a similar feature.

just my $0.02
Robert
Jul 19 '05 #60

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
9527
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
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...
0
10223
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
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,...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
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
5441
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...
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.