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

Survey Results

Do you use block markers (eg. {}, begin/end) when the code block is only a single line?

Survey period: 11 Oct 2021 to 18 Oct 2021

Consistency or compactness? What's your preferred way of marking blocks of code?

OptionVotes% 
I always wrap code blocks in block markers regardless of the number of lines in the block
if (condition) { statement; }
49152.97
I only use block markers when there is more than 1 line
if (condition) statement;
22223.95
The programming language I use requires I always use block markers131.40
I don't program in a language that uses block markers464.96
It depends (on my mood, my team mates, the current project, the language, the phase of the moon...)15516.72



 
GeneralUsed to "any", but now "Always" Pin
adriancs17-Oct-21 1:42
mvaadriancs17-Oct-21 1:42 
GeneralSelf Interest Pin
Patrick Wimberly13-Oct-21 4:21
Patrick Wimberly13-Oct-21 4:21 
The problem with not marking the code is not with the original authoring but later in the life of the code. Usually, less experienced people are put into support roles and they sometimes do not look carefully at what they are doing. They add another line to the if block but do not notice that there are no curly braces. They then show up complaining that your code does not work right at which point you must take the time to look at it and, hopefully, see the lack of braces. You can handle this several ways: One, a learning experience for your greenbean or Two, a chance to mercilessly ridicule the less experienced. Of course, there is always three, you don't notice it yourself and end up looking like a jackass.
GeneralClarity always counts PinPopular
YrthWyndAndFyre13-Oct-21 3:19
YrthWyndAndFyre13-Oct-21 3:19 
GeneralNo (usually). Pin
Jon McKee12-Oct-21 20:32
professionalJon McKee12-Oct-21 20:32 
GeneralDepends Pin
Julian Ragan12-Oct-21 11:30
Julian Ragan12-Oct-21 11:30 
GeneralAlways Pin
obermd12-Oct-21 9:36
obermd12-Oct-21 9:36 
QuestionFor folks who selected "I don't program in a language that uses block markers" Pin
Vikram A Punathambekar12-Oct-21 6:58
Vikram A Punathambekar12-Oct-21 6:58 
AnswerRe: For folks who selected "I don't program in a language that uses block markers" Pin
Nagy Vilmos15-Oct-21 1:19
professionalNagy Vilmos15-Oct-21 1:19 
AnswerRe: For folks who selected "I don't program in a language that uses block markers" Pin
trønderen15-Oct-21 12:38
trønderen15-Oct-21 12:38 
GeneralAlmost always Pin
sasadler12-Oct-21 6:08
sasadler12-Oct-21 6:08 
GeneralThis sounds like an interview question! Pin
AndyChisholm12-Oct-21 4:58
AndyChisholm12-Oct-21 4:58 
GeneralI put them in; CodeMaid takes them out! Pin
StarNamer@work12-Oct-21 4:41
professionalStarNamer@work12-Oct-21 4:41 
GeneralRe: I put them in; CodeMaid takes them out! Pin
Paul Sanders (the other one)12-Oct-21 7:45
Paul Sanders (the other one)12-Oct-21 7:45 
GeneralRe: I put them in; CodeMaid takes them out! Pin
StarNamer@work12-Oct-21 12:32
professionalStarNamer@work12-Oct-21 12:32 
GeneralNo Python then Pin
Bruce Patin12-Oct-21 3:51
Bruce Patin12-Oct-21 3:51 
GeneralMy preference mostly depends on the language/coding style Pin
Dan Neely12-Oct-21 3:38
Dan Neely12-Oct-21 3:38 
GeneralOnly for work... Pin
decaffeinatedMonkey12-Oct-21 3:34
decaffeinatedMonkey12-Oct-21 3:34 
GeneralI program in C, C++, and C# and always use block markers Pin
Daniel Pfeffer11-Oct-21 22:15
professionalDaniel Pfeffer11-Oct-21 22:15 
GeneralRe: I program in C, C++, and C# and always use block markers Pin
Stuart Dootson12-Oct-21 5:18
professionalStuart Dootson12-Oct-21 5:18 
GeneralRe: I program in C, C++, and C# and always use block markers Pin
Greg Utas13-Oct-21 2:23
professionalGreg Utas13-Oct-21 2:23 
GeneralRe: I program in C, C++, and C# and always use block markers Pin
Nelek13-Oct-21 4:39
protectorNelek13-Oct-21 4:39 
GeneralRe: I program in C, C++, and C# and always use block markers Pin
peterkmx17-Oct-21 9:18
professionalpeterkmx17-Oct-21 9:18 
GeneralMISRA C Pin
den2k8811-Oct-21 20:46
professionalden2k8811-Oct-21 20:46 
GeneralRe: MISRA C Pin
trønderen15-Oct-21 12:45
trønderen15-Oct-21 12:45 
GeneralALWAYS block markers and multiline PinPopular
KarstenK11-Oct-21 20:29
mveKarstenK11-Oct-21 20:29 

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.