|
petriiik wrote: If whitespace is friend, why not to use space also after "if" word?
That was something I accidentally didn't correct after the copy & paste. I agree 100%, I go so far as doing a global search and replace on "if(" --> "if (" if I find a file that was written that way.
He said, "Boy I'm just old and lonely,
But thank you for your concern,
Here's wishing you a Happy New Year."
I wished him one back in return.
|
|
|
|
|
I liked your first post and I too dislike not having white space after the if. However, I don't consider it the end of the world though.
Kevin
|
|
|
|
|
Our coding standard would require an additional step:
if (a != 3
&& a!= 5)
{
a = b + (4 * c);
}
We have a single evaluatable conditional per line
If you vote me down, my score will only get lower
|
|
|
|
|
Roger Allen wrote:
if (a != 3
&& a!= 5)
{
a = b + (4 * c);
}
Yeah, for longer statements, ifs are broken into multiple lines. It depends on the case. And for grouping higher precedence operations (i.e. "4*c")it "feels" clearer to me, though I still use parentheses when it isn't instantly clear.
I chose not to enforce coding standards across all our developers (within reason, some things need to be global, like tabs=3 spaces and there no tab characters). This way, I can *instantly* tell who wrote something when I look at a piece of code, or at least tell that it wasn't me It's quicker than using svn blame.
We're a small department though (3-4 developers max), larger companies probably couldn't get away with that.
He said, "Boy I'm just old and lonely,
But thank you for your concern,
Here's wishing you a Happy New Year."
I wished him one back in return.
|
|
|
|
|
gag (sticking finger down throat...)
toss in a pair of parens:
if ( (a != 3) && (a != 5) )
{
... do something useful
}
If the conditional is quite long, the perhaps break it across two lines,
but have you ever noticed that coding standards (nothing wrong with them) have
not evolved past 80 char terminals?
Charlie Gilley
<italic>You're going to tell me what I want to know, or I'm going to beat you to death in your own house.
"Where liberty dwells, there is my country." B. Franklin, 1783
“They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759
|
|
|
|
|
Actually, I dislike the extra parentheses because in this case the condition without them is semantically unambiguous. The extra parentheses just add clutter and can actually decrease readability with more elaborate conditionals.
Kevin
|
|
|
|
|
That seems over-finicky to me. I only do it when the expressions are either long or complex. This is the kind of thing which I would have a s a guideline in a coding standard. "CONSIDER doing X" rather than "You MUST..."
Kevin
|
|
|
|
|
No real men use
test eax, eax
jz $loop
We don't need no stinking curly (girly) brackets!
|
|
|
|
|
|
Gaaaahhh! My eyes! The goggles! They do nothing!
|
|
|
|
|
Quiche Eater! Real programmers don't do structured programming!
|
|
|
|
|
Nope, I wrap them in BACON.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
hmmmmm
|
|
|
|
|
That would be code-in-a-blanket?
|
|
|
|
|
I prefer to think of it as a Perfect Code Sandwich.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
Then I reakon I can get fries with that eh?
|
|
|
|
|
Youse just tryin' ta git ma t'say t'Magic Words, y-all!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
A BLC? Bacon, Lettuce and Code sandwich?
Why can't I be applicable like John? - Me, April 2011 ----- Beidh ceol, caint agus craic againn - Seán Bán Breathnach ----- Da mihi sis crustum Etruscum cum omnibus in eo! ----- Just because a thing is new don’t mean that it’s better - Will Rogers, September 4, 1932
|
|
|
|
|
Johnny J. wrote: Bacon, lettuce and Code sandwich
FTFY!
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
Manfred R. Bihy: "Looks as if OP is learning resistant."
|
|
|
|
|
5
Bacon replies are timely and awesome !
|
|
|
|
|
Thief[^]!
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
Have a bit more patience with newbies. Of course some of them act dumb -- they're often *students*, for heaven's sake. -- (Terry Pratchett, alt.fan.pratchett)
|
|
|
|
|
Since when usage of unnecessary symbols has started improving readability? And aren't we suppose to consistently try to minimize amount of code we write?
|
|
|
|
|
Exactly. Curly braces are noise. Languages with good syntax don't even have them.
|
|
|
|
|
Agreed. Superior languages such as VB.NET don't have stupid braces.
|
|
|
|
|
I really had in mind ML and Python
|
|
|
|