Click here to Skip to main content
15,879,047 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 
In my early years, there is no specific standard for this. It's totally depends on current mood.

But after years and projects, sooner or later, I realized that doing it with markers will make the code block more maintainable, less bugs, more easier for expansion, more readable by human, less confusion. It makes life more easier at later time whenever I needed to come back to debug the code block.

In quite a number of times when I came to the same block, I needed to re-add the markers for performing further additional coding lines and variables for other logic test, etc. So, next time whenever I code this part, I'll always add the markers, this is because I know there's a high percentage that I will still need to re-add it in future (especially while debugging).
GeneralSelf Interest Pin
Patrick Wimberly13-Oct-21 4:21
Patrick Wimberly13-Oct-21 4:21 
GeneralClarity always counts Pin
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 PinPopular
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.