Click here to Skip to main content
15,881,600 members

Survey Results

Braces around single line commands. Needed or not?

Survey period: 12 Feb 2018 to 19 Feb 2018

It's just about the braces. Not about whether the leading brace should or should not be on the same line as the conditional. One war at a time.

OptionVotes% 
I prefer

if (condition)
  statement;
21323.20
I prefer

if (condition)
{
  statement;
}
54158.93
It depends16417.86



 
GeneralRe: The least keystrokes Pin
Ravi Bhavnani12-Feb-18 5:20
professionalRavi Bhavnani12-Feb-18 5:20 
GeneralRe: The least keystrokes Pin
PeejayAdams13-Feb-18 1:19
PeejayAdams13-Feb-18 1:19 
GeneralRe: The least keystrokes Pin
Richard Andrew x6413-Feb-18 8:59
professionalRichard Andrew x6413-Feb-18 8:59 
GeneralRe: The least keystrokes Pin
Bassam Abdul-Baki15-Feb-18 3:45
professionalBassam Abdul-Baki15-Feb-18 3:45 
GeneralRe: The least keystrokes Pin
Richard Andrew x6415-Feb-18 11:57
professionalRichard Andrew x6415-Feb-18 11:57 
Generalbraces should be required and properly formatted Pin
Dennis E White12-Feb-18 4:49
professionalDennis E White12-Feb-18 4:49 
GeneralRe: braces should be required and properly formatted Pin
PeejayAdams13-Feb-18 1:21
PeejayAdams13-Feb-18 1:21 
GeneralIt definitely depends and the key differentiater is where the opening one goes Pin
Dan Neely12-Feb-18 4:32
Dan Neely12-Feb-18 4:32 
If you're doing it like this:
C#
if (whatever) {
   DoStuff();
   DoMoreStuff();
}

if (something) {
   DoAThing();
}

you need them even for one liners to preseve visbility and because in javascript the auto semicolon inserter will blow up in your face if you don't.

OTOH if you put the opening brace on its own line
C#
if (whatever) 
{
   DoStuff();
   DoMoreStuff();
}

if (something) 
   DoAThing();

the normal increased visibility of the opening one makes accidentally assuming a closing one too a lot harder and IMO unneeded.
Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason?
Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful?
--Zachris Topelius

Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies.
-- Sarah Hoyt

GeneralIs Switch Case part of other? Pin
MarcusCole683312-Feb-18 4:31
professionalMarcusCole683312-Feb-18 4:31 
GeneralBraces. Pin
Ron Anders12-Feb-18 3:04
Ron Anders12-Feb-18 3:04 
GeneralRe: Braces. Pin
Chris Maunder12-Feb-18 9:37
cofounderChris Maunder12-Feb-18 9:37 
GeneralAlways use curly braces Pin
ZurdoDev12-Feb-18 2:14
professionalZurdoDev12-Feb-18 2:14 
GeneralI prefer... Pin
Slacker00712-Feb-18 1:32
professionalSlacker00712-Feb-18 1:32 
GeneralRe: I prefer... Pin
ZurdoDev12-Feb-18 2:10
professionalZurdoDev12-Feb-18 2:10 
GeneralRe: I prefer... Pin
Slacker00712-Feb-18 2:12
professionalSlacker00712-Feb-18 2:12 
GeneralRe: I prefer... Pin
W Balboos, GHB12-Feb-18 2:52
W Balboos, GHB12-Feb-18 2:52 
GeneralThe usual b&tching Pin
W Balboos, GHB12-Feb-18 0:23
W Balboos, GHB12-Feb-18 0:23 
GeneralRe: The usual b&tching Pin
Slacker00712-Feb-18 1:25
professionalSlacker00712-Feb-18 1:25 
GeneralRe: The usual b&tching Pin
gardnerp12-Feb-18 1:55
gardnerp12-Feb-18 1:55 
GeneralRe: The usual b&tching Pin
ZurdoDev12-Feb-18 2:11
professionalZurdoDev12-Feb-18 2:11 
GeneralRe: The usual b&tching Pin
W Balboos, GHB12-Feb-18 2:13
W Balboos, GHB12-Feb-18 2:13 
GeneralRe: The usual b&tching Pin
ZurdoDev12-Feb-18 2:16
professionalZurdoDev12-Feb-18 2:16 
GeneralRe: The usual b&tching Pin
W Balboos, GHB12-Feb-18 2:21
W Balboos, GHB12-Feb-18 2:21 
GeneralRe: The usual b&tching Pin
ZurdoDev12-Feb-18 2:31
professionalZurdoDev12-Feb-18 2:31 
GeneralRe: The usual b&tching Pin
W Balboos, GHB12-Feb-18 2:32
W Balboos, GHB12-Feb-18 2:32 

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.