Click here to Skip to main content
15,918,211 members

Survey Results

Do you wrap single line statements in braces (or begin/end)?   [Edit]

Survey period: 16 May 2011 to 23 May 2011

Do you:

if (condition)
    statement
or
if (condition)
{
    statement
}
(Replace {}'s with Begin/End or whatever is appropriate for your language du jour)

OptionVotes% 
I always wrap single line statements95548.04
I sometimes wrap single line statements57328.82
I never wrap single line statements - only multiple lines get wrapped.46023.14



 
GeneralRe: Neither Pin
bob1697216-May-11 6:40
bob1697216-May-11 6:40 
GeneralRe: Neither Pin
QuiJohn16-May-11 10:31
QuiJohn16-May-11 10:31 
GeneralRe: Neither Pin
Paul Klomp16-May-11 20:15
Paul Klomp16-May-11 20:15 
GeneralRe: Neither Pin
petriiik16-May-11 21:42
petriiik16-May-11 21:42 
GeneralRe: Neither Pin
QuiJohn17-May-11 4:27
QuiJohn17-May-11 4:27 
GeneralRe: Neither Pin
Kevin McFarlane21-May-11 6:08
Kevin McFarlane21-May-11 6:08 
GeneralRe: Neither Pin
Roger Allen16-May-11 23:42
Roger Allen16-May-11 23:42 
GeneralRe: Neither Pin
QuiJohn17-May-11 4:32
QuiJohn17-May-11 4:32 
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 Smile | :) 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.

GeneralRe: Neither Pin
charlieg18-May-11 14:33
charlieg18-May-11 14:33 
GeneralRe: Neither Pin
Kevin McFarlane21-May-11 6:12
Kevin McFarlane21-May-11 6:12 
GeneralRe: Neither Pin
Kevin McFarlane21-May-11 6:18
Kevin McFarlane21-May-11 6:18 
GeneralRe: Neither Pin
Mike Hankey16-May-11 9:06
mveMike Hankey16-May-11 9:06 
GeneralRe: Neither Pin
PatmanV17-May-11 0:04
PatmanV17-May-11 0:04 
GeneralRe: Neither Pin
peterchen16-May-11 23:51
peterchen16-May-11 23:51 
GeneralRe: Neither Pin
Mladen Janković17-May-11 4:52
Mladen Janković17-May-11 4:52 
GeneralNope Pin
OriginalGriff16-May-11 3:55
mveOriginalGriff16-May-11 3:55 
GeneralRe: Nope Pin
Albert Holguin16-May-11 7:21
professionalAlbert Holguin16-May-11 7:21 
GeneralRe: Nope Pin
Mike Hankey16-May-11 9:07
mveMike Hankey16-May-11 9:07 
GeneralRe: Nope Pin
OriginalGriff16-May-11 9:16
mveOriginalGriff16-May-11 9:16 
GeneralRe: Nope Pin
Mike Hankey16-May-11 9:46
mveMike Hankey16-May-11 9:46 
GeneralRe: Nope Pin
OriginalGriff16-May-11 9:49
mveOriginalGriff16-May-11 9:49 
GeneralRe: Nope Pin
Johnny J.16-May-11 21:02
professionalJohnny J.16-May-11 21:02 
GeneralRe: Nope Pin
OriginalGriff16-May-11 21:25
mveOriginalGriff16-May-11 21:25 
GeneralRe: Nope Pin
Geekian_senate16-May-11 13:22
Geekian_senate16-May-11 13:22 
GeneralRe: Nope Pin
Nagy Vilmos17-May-11 2:01
professionalNagy Vilmos17-May-11 2:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.