I thought religious discussions were off-limits.
I agree well with most of what has been said. I also confess that I am guilty of having no specific format for variable and function names.
It's bad enough that I have asked for a "guide sheet" and I keep it open when writing new code. Also, when taking a break from writing, I often go back over the code looking for missed names.
There is one habit that I picked up deliberately, that is sometimes frowned on by others. It was suggested by a Comp-Sci professor over dinner one night. When comparing a variable to a constant,
I now always put the constant first. This has the rather nice side-effect of throwing an error if I forget the second equals sign. For example:
- Code: Select all
if(NULL == some_pointer)
{
DealWithNothing();
}
Now if I accidentally drop an equals, making this an assign instead of a compare:
- Code: Select all
if(NULL = some_pointer)
{
DealWithNothing();
}
I get an error that I cannot assign a value to NULL.
It's not "earth shattering", but it has removed one frequent flier from my bug list.
I'll lastly say that I try to keep an open mind, my coding style is always evolving, and hopefully always will.