Is there a standard way to name them or is it programmer's call?
Thank you.
Is there a standard way to name them or is it programmer's call?
Thank you.
It's a reason for the holy wars in the programmer's office. Kind of akin to the one true bracing style.
Stay away from Hungarian Notation. ;-)
Something very basic and pretty much universally accepted:
use nouns for variable names.
use verbs for function names.
This makes coding easier to understand.
Beyond that, there are lots and lots of "rules" - I suspect the other answers will provide a few.
Use your company's coding guidelines; challenge them if they are outdated (i.e. keep a list of changes at the top of the file despite using version control).
If you're the first programmer or doing it for yourself, decide on a set of coding guidelines that works for you, document it, and stick with it.
Here are the naming guidelines posted by the GNU folks; they're similar to many others and about as good:
http://www.gnu.org/prep/standards/html_node/Names.html#Names
Well,
I usually name functions as:
MyFunctionToDoSomething();
variables/members as:
my_var_to_accept_something;
global variables:
MY_GLOBAL_VARIABLE;
Above all I try to keep all my naming to this standard. I really don't know what notation this follows, but I'm not a big fan of the Hungarian notation, so...
BTW, I see a lot of people going to some lengths to write small names which later on they wont understand... I learned to don't do that for the same reason. After all most IDE have auto-complete features so using long names isn't really an issue.
Cheers
Name your variables in english.
Comment in english.
But if you must use a different language, then use it for all variables and comments. Don't mix english (other than keywords and library functions) with your language.
I hate to see code like:
void FreeT( void* puntero ) {
unsigned long size;
size = *(long*) ( (char*)puntero - offset );
// memcpy( &size ,, offset );
if ( !size ) return;
total_bloques --;
total_alocado -= size ;
free( (char*)puntero - offset );
}