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



 
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 
When it's an error detect and method fail condition, then is short, sweet and single line:
So
C#
if (inputList.Count == 0) return;
Or
C#
if (inputList == null) throw new ArgumentException("inputList cannot be empty");


I grew up having to indent code manually, and I learned the hard way that
C++
if (a == b)
   c;
   d;
does not do what it looks like it does, particularly when you edit code and add c or d!
If the brackets are there to start with, it's pretty obvious:
C++
if (a == b)
   {
   c;
   }
   d;
Modern IDE's make it a whole load easier, but ... good habits are hard to break!
Sent from my Amstrad PC 1640
Never throw anything away, Griff
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
AntiTwitter: @DalekDave is now a follower!

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 
GeneralRe: Most single statements won't stay single Pin
Kevin McFarlane28-Aug-18 3:30
Kevin McFarlane28-Aug-18 3:30 
GeneralRe: Most single statements won't stay single Pin
kalberts28-Aug-18 1:35
kalberts28-Aug-18 1:35 
GeneralNearly always Pin
PIEBALDconsult26-Aug-18 18:15
mvePIEBALDconsult26-Aug-18 18:15 

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.