Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I want to know the programming style of all good programmers all over the world.
Programmer in Microsoft C++, Programmer in Linux, companies and many good students, professors everywhere and anybody who thinks she/he is a good programmer.

In brief, I only want to have one criterion.

Example:
__STD::swap(_M_start, __x._M_start);
__STD::swap(_M_finish, __x._M_finish);
__STD::swap(_M_end_of_storage, __x._M_end_of_storage);


I don't like _ and __ and what do they mean.
Posted
Updated 2-Jun-10 12:04pm
v4

May be you'll not like my answer but ... there is no answer for such a question.

Programming style is somewhat personal. There can be guidelines in use in companies, communities etc. but -as far my experience is(30 yers of programming)- they are always more or less violated by their own programmers.

The only recommendation I can give is to find yourself a style that lets you comfortable and -more important- be coherent with it. Don't change it halfway in a file, project etc.

Serious companies and programmers will understand it and follow it when using your sources.
 
Share this answer
 
v2
Emilio gave you a good answer.

One thing I can recommend is to follow the style of the standard library for the language you are using. For instance, with C or C++ that would be the K&R style[^] (yes, lots of underscores :) ).
 
Share this answer
 
I know that : There are many answers for one question like many styles in programming.

I am not easy when i read their code, because i don't know their style code. If they share code i think they should share programming style.

Many styles, but i want they are followed guidelines. Guidelines followed them, i don't care but i want to know when they share code.

I think if i know the rules, i will work better.

I always wait new answers. Thank all you.
 
Share this answer
 
v2
Obviously, your example is from the C++ standard library.
the underline prefix __ is often seen in a library source.
because this style can avoid conflicting variable name with client code(the code using the library)

If not coding a library. I don't think this style is a good idea any more.

so, there is no criterion. just satisfy your needs.
think about it, what problem the style solves?
 
Share this answer
 
Look at the context of the code you're reading - it's taken from a standard library implementation and the authors wanted to make sure their code works with a wide variety of compilers. So for really old festering piles of bits that don't understand namespaces they can just do something like:

#define __STD


and hey presto it'll compile.

So why do they use double underscores? Well if you read the C++ standard you'll see that identifiers with two underscores ANYWHERE in the name are reserved. That means compiler vendors only. Using double underscores is a great way of a compiler vendor keeping their identifiers out of the collision scope of user programs.

Identifiers starting with single underscores are reserved for library vendors for the same reasons.

Cheers,

Ash
 
Share this answer
 
Comments
Member 13101494 4-Jun-17 12:52pm    
which method to use in php to easy programming in php

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900