coding standard

B

benben

Is there an effort to unify the c++ coding standard? Especially
identifier naming.

Not a big issue but it would be annoying to have to incorporate
different coding styles simultaneously when using more than one library.
The standard library seems to have everything lower-cased while a lot of
other libraries do their own way.

Ben
 
J

John Carson

benben said:
Is there an effort to unify the c++ coding standard? Especially
identifier naming.

Sure. There are also efforts underway to color-coordinate programmers'
clothing and to make all ball-point pens the same size. Stay tuned for some
breakthroughs.
 
O

osmium

"benben"
Is there an effort to unify the c++ coding standard? Especially identifier
naming.

Not a big issue but it would be annoying to have to incorporate different
coding styles simultaneously when using more than one library. The
standard library seems to have everything lower-cased while a lot of other
libraries do their own way.

It's an esthetic issue isn't it? The only successful control of esthetics I
know of was the clothing of citizen's in Communist China. Now, even that
has failed.

It annoys me too.
 
B

benben

osmium said:
"benben"


It's an esthetic issue isn't it? The only successful control of esthetics I
know of was the clothing of citizen's in Communist China. Now, even that
has failed.

It annoys me too.

"Control" is too strong a word...I would rather use "recommend". As I
said it is not really a big issue and I have accepted it for years, but
wouldn't it be more ideal if...

Regards,
Ben
 
P

Phlip

benben said:
Is there an effort to unify the c++ coding standard? Especially identifier
naming.

As a Best Practice, a new member of a team should start writing in the
existing code's esthetic style. No more indenting {} just because everyone
else outdents them {}.
Not a big issue but it would be annoying to have to incorporate different
coding styles simultaneously when using more than one library. The
standard library seems to have everything lower-cased while a lot of other
libraries do their own way.

The book /Elements of C++ Style/ is a nice little guide to esthetic issues.
Things like CONSTANTS in all-caps.

And non-Standard libraries should _not_ emulate the C library style that the
C++ library derived from. (Caps were hard to type on ancient terminals;-)
 
H

Howard

benben said:
Is there an effort to unify the c++ coding standard? Especially identifier
naming.

Not a big issue but it would be annoying to have to incorporate different
coding styles simultaneously when using more than one library. The
standard library seems to have everything lower-cased while a lot of other
libraries do their own way.

Ben

I hope not, because it seems that everyone has at least a _slightly_
different coding style. (And we all KNOW that my coding style is the only
proper one!) :)

-Howard
 
D

Daniel T.

"Phlip said:
As a Best Practice, a new member of a team should start writing in the
existing code's esthetic style. No more indenting {} just because everyone
else outdents them {}.


The book /Elements of C++ Style/ is a nice little guide to esthetic issues.
Things like CONSTANTS in all-caps.

And non-Standard libraries should _not_ emulate the C library style that the
C++ library derived from. (Caps were hard to type on ancient terminals;-)

Actually, it's kind of nice that each library uses a different style. I
know what library the function belongs to just by looking at the style.
:)

A better reason not to use the same style as the standard library. Name
collisions...
 
G

Gavin Deane

Daniel said:
Actually, it's kind of nice that each library uses a different style. I
know what library the function belongs to just by looking at the style.
:)

A better reason not to use the same style as the standard library. Name
collisions...

Given the choice, I write code in the same style as the standard
library - after all it is the most beautiful. Capital letters are an
aberration :)

But more seriously, while I happen to like the same style, I don't
write code in the std namespace. Code I want others to use will be in
its own namespace. I consider that sufficient protection against name
clashes (that being the purpose of namespaces). Why would it not be?
Are you only worried about clients who abuse using declarations and
directives, or is there something else?

Gavin Deane
 
N

Noah Roberts

benben said:
Is there an effort to unify the c++ coding standard? Especially
identifier naming.

Not a big issue but it would be annoying to have to incorporate
different coding styles simultaneously when using more than one library.
The standard library seems to have everything lower-cased while a lot of
other libraries do their own way.

Read recommendation #1 of Sutter and Andrescu.
 
P

Phlip

Howard said:
I hope not, because it seems that everyone has at least a slightly
different coding style.  (And we all KNOW that my coding style is the only
proper one!) :)

Teamwork is very important in programming. Nobody should "mark their
territory" in code, and the ideal situation is where nobody can tell who
wrote what code just by looking at it.
 
B

benben

Given the choice, I write code in the same style as the standard
library - after all it is the most beautiful. Capital letters are an
aberration :)

Some people may think the same. As for me, it doesn't really matter.
What bothers me is the inconsistency.

Regards,
Ben
 
B

benben

Howard said:
I hope not, because it seems that everyone has at least a _slightly_
different coding style. (And we all KNOW that my coding style is the only
proper one!) :)

-Howard

I might not have made myself very clear in my post. And let me clarify.

I don't mind different styles--that's how you learn from other people.
But, no matter what style you are coding in, it must be consistent. That
is, you follow a certain rule, whatever it is, to name identifiers and
format your code throughout.

But this is very difficult because you eventually may have to use some
libraries that follow different styles. It is not the coding style as a
whole that is troublesome, but the way the public interface is named and
formatted can be significant.

What is in my mind is that perhaps we should (would) at least name our
public interface in a consistent way with other libraries so when more
than one libraries are used the user would at least have consistent user
code.

And you can still keep your personality in your local code as long as it
is not in the public interface. This is more than just pure aesthetics.
It is more about readability.

Regards,
Ben
 
B

benben

Actually, it's kind of nice that each library uses a different style. I
know what library the function belongs to just by looking at the style.
:)

Sometimes. But when two libraries have similar functions I am quite
reluctant to rely on "style" for disambiguation (for me, not for the
compiler of course.) A better qualified name is more explicit and readable.
A better reason not to use the same style as the standard library. Name
collisions...

There is actually a reason why names collide. After all, they mostly
stand for some more subtle problems, don't they. Again, instead of
relying on styles for preventing name collision it is far better to just
use namespace to qualify them, so that when you read the code, you know
exactly which library it is about.

Regards,
Ben
 
P

P.J. Plauger

Sometimes. But when two libraries have similar functions I am quite
reluctant to rely on "style" for disambiguation (for me, not for the
compiler of course.) A better qualified name is more explicit and
readable.


There is actually a reason why names collide. After all, they mostly stand
for some more subtle problems, don't they.
Huh?

Again, instead of relying
on styles for preventing name collision it is far better to just use
namespace to qualify them, so that when you read the code, you know
exactly which library it is about.

That works fine for everything but macro names.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top