Click here to Skip to main content
15,921,463 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



 
GeneralOnly if they're really a single line [modified] Pin
Gary Wheeler16-May-11 1:43
Gary Wheeler16-May-11 1:43 
GeneralRe: Only if they're really a single line Pin
Nemanja Trifunovic16-May-11 2:08
Nemanja Trifunovic16-May-11 2:08 
GeneralRe: Only if they're really a single line Pin
Gary Wheeler16-May-11 2:10
Gary Wheeler16-May-11 2:10 
GeneralRe: Only if they're really a single line Pin
Nemanja Trifunovic16-May-11 2:21
Nemanja Trifunovic16-May-11 2:21 
GeneralRe: Only if they're really a single line Pin
Gary Wheeler16-May-11 2:28
Gary Wheeler16-May-11 2:28 
GeneralRe: Only if they're really a single line Pin
Nemanja Trifunovic16-May-11 3:56
Nemanja Trifunovic16-May-11 3:56 
GeneralRe: Only if they're really a single line Pin
Gary Wheeler16-May-11 4:02
Gary Wheeler16-May-11 4:02 
GeneralRe: Only if they're really a single line Pin
QuiJohn16-May-11 2:26
QuiJohn16-May-11 2:26 
I believe everything you outlined should be pounded into every new C/C++/C# student until it's second nature.

if (condition) DoSomething();


I used to shun this but now use it for strings of similar, ultra simplistic ifs. It looks clean, and if used in the right place is staggeringly obvious what it's doing. Not, as I have seen:

if (condition) x ? y : z;


And x, y and z are greatly abbreviated here. *shudder*

For the other cases, I type both braces as part of typing the if (or for, or whatever), before I type any of the contents, regardless of if it's only 1 line.

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: Only if they're really a single line Pin
Gary Wheeler16-May-11 2:30
Gary Wheeler16-May-11 2:30 
GeneralRe: Only if they're really a single line Pin
charlieg16-May-11 9:35
charlieg16-May-11 9:35 
GeneralRe: Only if they're really a single line Pin
Amar Chaudhary16-May-11 2:31
Amar Chaudhary16-May-11 2:31 
GeneralRe: Only if they're really a single line Pin
Gary Wheeler16-May-11 2:34
Gary Wheeler16-May-11 2:34 
GeneralRe: Only if they're really a single line Pin
charlieg16-May-11 9:36
charlieg16-May-11 9:36 
GeneralRe: Only if they're really a single line Pin
Vark11117-May-11 9:45
Vark11117-May-11 9:45 
GeneralIt Depends Pin
Bassam Abdul-Baki16-May-11 0:41
professionalBassam Abdul-Baki16-May-11 0:41 
GeneralRe: It Depends Pin
Kevin McFarlane21-May-11 6:33
Kevin McFarlane21-May-11 6:33 
GeneralOther Pin
Nagy Vilmos16-May-11 0:16
professionalNagy Vilmos16-May-11 0:16 
GeneralRe: Other Pin
Chris Meech16-May-11 1:44
Chris Meech16-May-11 1:44 
GeneralRe: Other Pin
Nagy Vilmos16-May-11 3:39
professionalNagy Vilmos16-May-11 3:39 
GeneralRe: Other Pin
OriginalGriff17-May-11 2:22
mveOriginalGriff17-May-11 2:22 
GeneralI think it is being lazy Pin
Slacker00715-May-11 23:56
professionalSlacker00715-May-11 23:56 
GeneralLaziness is a virtue... Pin
Nemanja Trifunovic16-May-11 4:07
Nemanja Trifunovic16-May-11 4:07 
GeneralRe: Laziness is a virtue... Pin
Slacker00716-May-11 4:28
professionalSlacker00716-May-11 4:28 
GeneralRe: I think it is being lazy Pin
Mladen Janković16-May-11 5:12
Mladen Janković16-May-11 5:12 
GeneralOn related lines - If and Else Pin
Jyothikarthik_N15-May-11 23:50
Jyothikarthik_N15-May-11 23:50 

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.