C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Coding guidelines/Notation

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Iguana
Guest





PostPosted: Wed Jan 19, 2005 9:19 pm    Post subject: Coding guidelines/Notation Reply with quote



A few questions, is there a most commonly used hungarian notation that
everyone uses (or similar notation)?

Secondly, I've read a few coding guidelines, but none really seem to hit
home with me (I don't really agree with some of the things they're saying
with respect to readability). Is there a "Top 10 Coding Guidelines" list,
or somewhere where I can find a standardized (or similar) guideline?

Lastly, I'm getting the idea that layout is mostly down to the coder, after
you take things like readability into account. Is this reasonably accurate?

Thanks,
Iguana



[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Jack Klein
Guest





PostPosted: Thu Jan 20, 2005 11:58 am    Post subject: Re: Coding guidelines/Notation Reply with quote



On 19 Jan 2005 16:19:48 -0500, Iguana <hairnet (AT) f2s (DOT) com> wrote in
comp.lang.c++.moderated:

Quote:
A few questions, is there a most commonly used hungarian notation that
everyone uses (or similar notation)?

No, "Hungarian" notation is a dead issue.

Quote:
Secondly, I've read a few coding guidelines, but none really seem to hit
home with me (I don't really agree with some of the things they're saying
with respect to readability). Is there a "Top 10 Coding Guidelines" list,
or somewhere where I can find a standardized (or similar) guideline?

Can't help.

Quote:
Lastly, I'm getting the idea that layout is mostly down to the coder, after
you take things like readability into account. Is this reasonably accurate?

No, unless you are talking about a single programmer working in
complete isolation. Any organization committed to quality software
has code inspections, and has mandatory guidelines for layout so
inspection time is not wasted by constantly adjusting from one
programmer's "style" to the other's.

One of the things that keeps software development in its infancy, with
the terrible track record that it has, is that prima donna programmers
have convinced undereducated managers that things like layout, naming
rules, and quite a few other things are "style" issues that should be
left to the individual programmer.

Any organization that has a clue has specific coding requirements, and
programmers who persist in non-conformance after sufficient warnings
are replaced, no matter how "good" they are otherwise.

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
David B. Held
Guest





PostPosted: Thu Jan 20, 2005 12:24 pm    Post subject: Re: Coding guidelines/Notation Reply with quote



Iguana wrote:
Quote:
A few questions, is there a most commonly used hungarian notation that
everyone uses (or similar notation)?

Yes. It's the null notation (meaning, most coders don't use Hungarian
any more). Boost follows the convention adopted by the standard, which
is to use lowercase names for concrete identifiers with words separated
by underscores, and capitalized names for template parameters. I think
the consensus is that codifying the type in the name is brittle and adds
little value. I personally use an additional convention where I append
an underscore to the names of private identifiers (whether they are
class members or private to a module). Other than that, I think there
is also a consensus that complete words make for better identifiers than
cryptic abbreviations. I still use identifiers like "i" and "x" where
appropriate, but for less local names I prefer more or less complete
names.

Quote:
Secondly, I've read a few coding guidelines, but none really seem to hit
home with me (I don't really agree with some of the things they're saying
with respect to readability). Is there a "Top 10 Coding Guidelines" list,
or somewhere where I can find a standardized (or similar) guideline?

You could take a look at Herb and Andrei's latest work: C++ Coding
Standards. It's probably as good as any other list you will find
(and maybe better than most).

Quote:
Lastly, I'm getting the idea that layout is mostly down to the coder, after
you take things like readability into account. Is this reasonably accurate?

Modulo consistency among members working on the same project, I would
agree. Then you have XP, which encourages all the code in an
organization to look indistinguishable w.r.t. the author. But if you
mean: "Is K&R brace formatting better or worse than BSD style?" then
I think most people would agree that there is no "right" answer to the
question.

Dave

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
kanze@gabi-soft.fr
Guest





PostPosted: Thu Jan 20, 2005 6:08 pm    Post subject: Re: Coding guidelines/Notation Reply with quote

Iguana wrote:
Quote:
A few questions, is there a most commonly used hungarian
notation that everyone uses (or similar notation)?

I think the consensus is that Hungarian notation is to be
avoided. About the most anyone I know puts in a name is whether
it is a member or non (non-members being almost exclusively
local variables or parameters). There are several prevailing
conventions for this: prefixing my (or our for static
member variables), prefixing m_ (s_), postfixing _, etc.

Quote:
Secondly, I've read a few coding guidelines, but none really
seem to hit home with me (I don't really agree with some of
the things they're saying with respect to readability). Is
there a "Top 10 Coding Guidelines" list, or somewhere where I
can find a standardized (or similar) guideline?

Some ten years back, "Programming in C++, Rules and
Recommendations", by Henricson and Nyquist (the Ellemtel
guidelines) ( http://www.doc.ic.ac.uk/lab/cplus/c++.rules/) was
pretty much the standard. Most of it is probably still pretty
good, but of course, it doesn't have much to say about templates
and exceptions, which are important aspects in modern C++.

Quote:
Lastly, I'm getting the idea that layout is mostly down to the
coder, after you take things like readability into account.
Is this reasonably accurate?

Not really. About the only consensus that you'll find
concerning layout is that everyone thinks that theirs is the
best. And a recognition amongst the more competent programmers
that the differences between the recognized layouts aren't
important enough to be worth fighting over. However, it is not
just down to the coder: layout within a project should be
consistent. The project should adopt one layout, and everybody
should stick with it. (Ditto for naming conventions.)

--
James Kanze GABI Software http://www.gabi-soft.fr
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Rene Moehring
Guest





PostPosted: Thu Jan 20, 2005 6:26 pm    Post subject: Re: Coding guidelines/Notation Reply with quote

On 20 Jan 2005 06:58:06 -0500, Jack Klein wrote:
Quote:
On 19 Jan 2005 16:19:48 -0500, Iguana <hairnet (AT) f2s (DOT) com> wrote in
comp.lang.c++.moderated:

A few questions, is there a most commonly used hungarian notation that
everyone uses (or similar notation)?

No, "Hungarian" notation is a dead issue.

Secondly, I've read a few coding guidelines, but none really seem to hit
home with me (I don't really agree with some of the things they're saying
with respect to readability). Is there a "Top 10 Coding Guidelines" list,
or somewhere where I can find a standardized (or similar) guideline?

Can't help.

Lastly, I'm getting the idea that layout is mostly down to the coder, after
you take things like readability into account. Is this reasonably accurate?

No, unless you are talking about a single programmer working in
complete isolation. Any organization committed to quality software
has code inspections, and has mandatory guidelines for layout so
inspection time is not wasted by constantly adjusting from one
programmer's "style" to the other's.

There are a lot of code beautifiers/indenters. That way adjusting is just

one app call away.
--
I'm not a racist. I hate everyone equally!

[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]

Back to top
Darren Bane
Guest





PostPosted: Thu Jan 20, 2005 6:47 pm    Post subject: Re: Coding guidelines/Notation Reply with quote

I concur that Hungarian notation is dead. You're supposed to use the
type system to do that job nowadays.

If you haven't already, you should read the FAQs on coding guidelines,
there is some good stuff there:

http://www.parashift.com/c++-faq-lite/coding-standards.html

If you're interested, in the past I had bad experience with managers
forcing me to write C in C++ because of organisational policy. This
almost convinced me to have no coding standards, but in the end I
relented, and plumped for the following:


[url]http://cvs.sourceforge.net/viewcvs.py/*checkout*/boost/boost/more/Attic/coding_guidelines.html?content-type=text%2Fplain&rev=1.1.2.6[/url]

(Sorry if that hyperlink splits, It should be all one line.)

I disagree that the mechanics of layout (tab width, tabs vs. spaces)
should be up to the coders. Standardising this has no ill effects,
other than annoying prima donnas (always a good outcome Smile ). Leaving
it unspecified means people waste time reformatting files to their
favourite style (albeit with the help of a good text editor). So far,
fairly harmless. Then they check it into your configuration management
system (you are using SCM, aren't you?) and it looks like they edited
every line in the file, when they might have only changed one.


[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.