By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,886 Members | 1,107 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,886 IT Pros & Developers. It's quick & easy.

Mixed case?

P: n/a
I'm totally new to C, so this is a question from a total newbie. I
know most people write the names in C with underscores,
as_in_this_name. But... is it also customary to write them in mixed
case, asWithThisName? Or is it a horrible horrible horrible thing to
do??
Jun 27 '08 #1
Share this Question
Share on Google+
9 Replies


P: n/a
On Apr 30, 8:59*pm, s0s...@gmail.com wrote:
I'm totally new to C, so this is a question from a total newbie. I
know most people write the names in C with underscores,
as_in_this_name. But... is it also customary to write them in mixed
case, asWithThisName? Or is it a horrible horrible horrible thing to
do??
IMHO, it is a horrible thing to do. Unless you are german... ;-)
Jun 27 '08 #2

P: n/a
On Apr 30, 2:59 pm, s0s...@gmail.com wrote:
I'm totally new to C, so this is a question from a total newbie. I
know most people write the names in C with underscores,
as_in_this_name. But... is it also customary to write them in mixed
case, asWithThisName? Or is it a horrible horrible horrible thing to
do??
There's no *technical* issue with using mixed case, and it appears to
be the more popular style where I've worked; I prefer it myself (more
natural typing than adding a bunch of underscores).
Jun 27 '08 #3

P: n/a
s0****@gmail.com wrote:
I'm totally new to C, so this is a question from a total newbie. I
know most people write the names in C with underscores,
as_in_this_name. But... is it also customary to write them in mixed
case, asWithThisName? Or is it a horrible horrible horrible thing to
do??
So-called "camel-case" isn't as traditional in C. I've seen in more
often in C++. That being said, when I worked on a major project at my
company in the mid-90s, the coding standard mandated camel-case rather
than underscores. It doesn't really matter to me in writing or reading
code which one is used. It's another case where consistency is probably
more important.

Brian
Jun 27 '08 #4

P: n/a
s0****@gmail.com wrote:
I'm totally new to C, so this is a question from a total newbie. I
know most people write the names in C with underscores,
as_in_this_name. But... is it also customary to write them in mixed
case, asWithThisName? Or is it a horrible horrible horrible thing to
do??
"Do what comes naturally." If you like under_scores, use
under_scores. If you like camelCase, use camelCase. If you
like thingsruntogether, runthingstogether. I'd encourage you,
as a beginner, to give all three styles (and others you may
find or invent) a try for a while, and see how it feels.

A few rules, though:

- If you're making changes to an existing program, use
that program's prevailing style. You may hate it, but
if you depart from it the other programmers will hate
you still more.

- Stick with one style throughout one program or library;
don't mix-and-match.

- Steer clear of "reserved identifiers." The C language
assigns meaning to some identifiers like printf, and
reserves the right to do so in the future with currently
unused identifiers like straphanger and isosceles. See
http://www.oakroadsystems.com/tech/c-predef.htm for a
list of some of these; it's out of date but will give
a useful heads-up.

- Most Of All: Do NOT!!! perpetuate that so-called
"Hungarian notation" abomination, a reasonable idea
that was twisted into a psychotic nightmare by weak-
brained enthusiasts.

--
Er*********@sun.com
Jun 27 '08 #5

P: n/a
s0****@gmail.com writes:
I'm totally new to C, so this is a question from a total newbie. I
know most people write the names in C with underscores,
as_in_this_name. But... is it also customary to write them in mixed
case, asWithThisName? Or is it a horrible horrible horrible thing to
do??
It's a personal preference issue. If you are working within an
existing collection of code that uses a given convention, then I
would advise sticking with that convention. If you are writing
your own code, then you can choose the convention that you
prefer.
--
"When I have to rely on inadequacy, I prefer it to be my own."
--Richard Heathfield
Jun 27 '08 #6

P: n/a
John Bode wrote:
On Apr 30, 2:59 pm, s0s...@gmail.com wrote:
>I'm totally new to C, so this is a question from a total newbie. I
know most people write the names in C with underscores,
as_in_this_name. But... is it also customary to write them in mixed
case, asWithThisName? Or is it a horrible horrible horrible thing to
do??

There's no *technical* issue with using mixed case, and it appears to
be the more popular style where I've worked; I prefer it myself (more
natural typing than adding a bunch of underscores).
CamelCase seems to have come from the C++ / Microsoft world in the last
decade or so. When I began programming, you justwrotewithoutspaces and
if you couldn't read them you were a wuss. I've seen_AllSorts of
lpszStupidConventions over the years tho.

--
Mark McIntyre

CLC FAQ <http://c-faq.com/>
CLC readme: <http://www.ungerhu.com/jxh/clc.welcome.txt>
Jun 27 '08 #7

P: n/a
Mark McIntyre wrote:

CamelCase seems to have come from the C++ / Microsoft world in the
last decade or so. When I began programming, you
justwrotewithoutspaces and if you couldn't read them you were a wuss.
I've seen_AllSorts of lpszStupidConventions over the years tho.

Well, in the old days you kept all those identifiers nice and short. If
people couldn't figure out what adjxref meant, then they weren't paying
attention. And that was the functions. Variables rarely needed to be
over three characters in length. "num" and "len" were good enough for
the pioneers, after all.


Brian
Jun 27 '08 #8

P: n/a
On Apr 30, 4:40 pm, Eric Sosman <Eric.Sos...@sun.comwrote:
- Most Of All: Do NOT!!! perpetuate that so-called
"Hungarian notation" abomination, a reasonable idea
that was twisted into a psychotic nightmare by weak-
brained enthusiasts.
Hear hear!

My previous job required Hungarian notation for all code, not just C,
but Java as well--which is even more ridiculous as Java is strongly
typed.

Jun 27 '08 #9

P: n/a
s0****@gmail.com wrote:
>
I'm totally new to C, so this is a question from a total newbie.
I know most people write the names in C with underscores,
as_in_this_name. But... is it also customary to write them in
mixed case, asWithThisName? Or is it a horrible horrible horrible
thing to do??
There is no problem with either technique. The problems arise if
you use leading '_' chars in names. And remember that there are
various reserved names (for the implementation).

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
** Posted from http://www.teranews.com **
Jun 27 '08 #10

This discussion thread is closed

Replies have been disabled for this discussion.