Click here to Skip to main content
15,889,527 members

Survey Results

When coding, do you put braces around single nested statements?

Survey period: 27 Aug 2018 to 3 Sep 2018

When coding using a language with braces, that is.

OptionVotes% 
Yes, always47536.48
Yes, mostly27120.81
Depends on the situation25019.20
Not usually16612.75
Never785.99
I don't code using a language with braces624.76



 
GeneralRe: Brace == indent Pin
Kewin Rausch2-Sep-18 22:58
professionalKewin Rausch2-Sep-18 22:58 
The problem never arise for the language itself; at the end compilers do their job in a quite good way. The problem comes when programmers (and not the original author) join this equation, so that they have to edit whatever is already there. This comes from experience in projects which lasts long and have multiple peoples joining efforts.

Too many time you see something like 'if(itsRaining) UseOmbrella();' becoming like 'if(itsRaining) UseOmbrella(); putOnBoots();' on the same line. The compiler will do it's job, and it will be correct by following the parsing rules, but the final outcome is wrong.

And again, not because the language is bugged, but becouse the human factor in programming has a really high impact factor (and must taken into account). There is a reason why software houses impose code-style and guidelines to programmer, and this is because everyone has it's own style, and this can impact future work done by some other programmers.

Between C peons like me there is the mantra of "always use parenthesis when writing pre-processore definitions".... and there is a reason for that! The if '(a + b == 8)' can assume a different meaning of what you do intend, and this happened to me!

That's why I'm defending my the portability, readability, extensibility of my code by using all the possible parenthesis and imposing an order which is "assumpted" to be correct (even when it's seems obvious), and this approach is giving fruits.

PS: Can you please provide a link to that study please, if you can? I'm interested now! Otherwise citing it does not make much sense, since it seems to be your opinion only, even if you say it's a paper/journal or whatsoever. In this era of fake new is dangerous to do claims such as "there is a study supporting my speech" without providing the source. Especially if your user name is "Member xxxxxxx".
GeneralDepends on the else Pin
daleofcourse27-Aug-18 22:28
daleofcourse27-Aug-18 22:28 
GeneralRe: Depends on the else Pin
Kevin McFarlane28-Aug-18 3:26
Kevin McFarlane28-Aug-18 3:26 
GeneralRe: Depends on the else Pin
Paulo Zemek28-Aug-18 11:19
mvaPaulo Zemek28-Aug-18 11:19 
GeneralBrace for Impact! Pin
MacSpudster27-Aug-18 10:39
professionalMacSpudster27-Aug-18 10:39 
GeneralNo? Pin
dandy7227-Aug-18 6:47
dandy7227-Aug-18 6:47 
Generalbut what about... Pin
Dennis E White27-Aug-18 4:56
professionalDennis E White27-Aug-18 4:56 
GeneralRe: but what about... Pin
kalberts28-Aug-18 1:03
kalberts28-Aug-18 1:03 
GeneralRe: but what about... Pin
Kevin McFarlane30-Aug-18 1:23
Kevin McFarlane30-Aug-18 1:23 
GeneralRe: but what about... Pin
Leng Vang30-Aug-18 8:41
Leng Vang30-Aug-18 8:41 
GeneralRarely omitted Pin
W Balboos, GHB27-Aug-18 3:28
W Balboos, GHB27-Aug-18 3:28 
GeneralIt's like deja-vu, all over again... Pin
littleGreenDude27-Aug-18 2:30
littleGreenDude27-Aug-18 2:30 
GeneralIts habit... Pin
koolprasad200326-Aug-18 20:55
professionalkoolprasad200326-Aug-18 20:55 
GeneralRe: Its habit... Pin
Kevin McFarlane28-Aug-18 3:33
Kevin McFarlane28-Aug-18 3:33 
GeneralMy Rule of Thumb Pin
Rick York26-Aug-18 20:48
mveRick York26-Aug-18 20:48 
GeneralReSharper Pin
Efe Erdoğru26-Aug-18 20:34
professionalEfe Erdoğru26-Aug-18 20:34 
GeneralRe: ReSharper Pin
Daniel Pfeffer26-Aug-18 20:46
professionalDaniel Pfeffer26-Aug-18 20:46 
GeneralRe: ReSharper Pin
Graeme_Grant26-Aug-18 21:51
mvaGraeme_Grant26-Aug-18 21:51 
GeneralRe: ReSharper Pin
GKP19921-Sep-18 2:33
professionalGKP19921-Sep-18 2:33 
GeneralThere is only one time when I don't. Pin
OriginalGriff26-Aug-18 20:30
mveOriginalGriff26-Aug-18 20:30 
GeneralRe: There is only one time when I don't. Pin
W Balboos, GHB27-Aug-18 3:20
W Balboos, GHB27-Aug-18 3:20 
GeneralMost single statements won't stay single Pin
henningbenk26-Aug-18 20:24
professionalhenningbenk26-Aug-18 20:24 
GeneralRe: Most single statements won't stay single Pin
Nemanja Trifunovic27-Aug-18 2:57
Nemanja Trifunovic27-Aug-18 2:57 
GeneralRe: Most single statements won't stay single Pin
dandy7227-Aug-18 6:55
dandy7227-Aug-18 6:55 
GeneralRe: Most single statements won't stay single Pin
Erik Burd27-Aug-18 12:34
professionalErik Burd27-Aug-18 12:34 

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.