Pet Peeve
-
I personally prefer this convention: if ((a cond b) conjunction (c cond d) conjunction // Additional conditions always on separate line (e cond f)) { // Always include opening brace do .... something } // Always closing brace Or } else { // Always closing brace..else..opening brace do .... something else } // Always closing brace The same conventions and principles apply to loops (for, while, etc.) and other conditionals. I strictly avoid NOT using braces under any circumstances. I want to be able to see a complete thought, i.e., a block of code, in one intact, obvious section. These are my thoughts based on years of chasing bugs, modifying other people's code, and having to debug somebody else's problem. Other people are welcome to use their own conventions, but I may not be able to help them efficiently. Just because I can do something doesn't mean I should do it.
It's interesting that the older the programmer the more concision becomes important. :)
Ron Christie
-
Why are people so lazy? For example, how hard is it to
if (condition)
{
DoThis();
}
else
{
DoThat();
}as opposed to:
if (condition)
DoThis();
else
DoThat();Pedants :sigh:
I have more
(condition)?DoThis():DoThat();
DoThese[(condition)]();
#define CALL_FUNC(__F) Do##__F
CALL_FUNC(condition);do
{
if(condition)
{
DoThis();
break;
}
} while(DoThat()&&condition);<pre lang="cs">
switch(condition)
{
case 1:
DoThis();
break;
default:
DoThat();
}:laugh: