Click here to Skip to main content
13,298,965 members (40,123 online)
Rate this:
Please Sign up or sign in to 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.

__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 6-Dec-09 4:00am
Updated 2-Jun-10 13:04pm
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

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 :) ).
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

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.
Rate this: bad
Please Sign up or sign in to vote.

Solution 4

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?
Rate this: bad
Please Sign up or sign in to vote.

Solution 5

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.


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)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.171207.1 | Last Updated 2 Jun 2010
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100