Click here to Skip to main content
15,890,282 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
GeneralCurly braces Pin
pkfox11-Dec-22 23:32
professionalpkfox11-Dec-22 23:32 
GeneralRe: Curly braces PinPopular
Jacquers11-Dec-22 23:37
Jacquers11-Dec-22 23:37 
GeneralRe: Curly braces Pin
honey the codewitch12-Dec-22 2:46
mvahoney the codewitch12-Dec-22 2:46 
GeneralRe: Curly braces Pin
fgs196312-Dec-22 3:22
fgs196312-Dec-22 3:22 
GeneralRe: Curly braces Pin
Jacquers12-Dec-22 3:37
Jacquers12-Dec-22 3:37 
GeneralRe: Curly braces Pin
trønderen12-Dec-22 4:30
trønderen12-Dec-22 4:30 
GeneralRe: Curly braces Pin
honey the codewitch12-Dec-22 5:40
mvahoney the codewitch12-Dec-22 5:40 
GeneralRe: Curly braces Pin
trønderen12-Dec-22 6:37
trønderen12-Dec-22 6:37 
Yes, like I said. But I do not undent until after the closing brace, so I would indent that as well (and include the break in the block).

Why not just do it? Because you sometimes have co-workers. For some time, I was using an embedded language (CHILL) which provided the loop construct FOR EVER DO - infinite loops are not uncommon in embedded software. In a new job, programming IoT in C, in one of the modules I was responsible for, I added a "#define ever ;;" for being able to program "for (ever) {...". After a few months, this was discovered by another programmer (not working on my module), who immediately searched through the entire repository to reveal ever use of such "programming jokes", changing them all to "while (0)", deleting the #define and adding a rude remark on the edit where he requested that all programmers refrain from such unserious coding practices in the future.

In the next scrum, he brought up his discovery, reporting to everybody how he had 'cleaned up' my code. I asked if he would accept "while (true)", but no: The proper way to code an infinite loop is "while (0)", with a zero. In classical C, "true" is a #define symbol, not part of the base language, and should not be used for fundamental things such as infinite loops.

I got no support from the team at all. Not even for "while (true)".

In a code review with the same team, I was asked why I would "clutter up" the code with such unnecessary braces in switch statements. I had the same remarks when I added braces to justify the indentation in one-line conditional statements, like
if (day == sunday) {
   relax();
}
The coding standard did not allow the "relax()" to be put on the same line as the "if", but mandated the indentation. It didn't explicitly forbid the braces I would like to add - but the programming team did, telling me to remove them.

That's how it is working in a team. You have to be obedient. Don't try to make code more readable, or consistent, or safer, if it breaks with the unwritten laws of the team.
GeneralRe: Curly braces Pin
honey the codewitch12-Dec-22 6:42
mvahoney the codewitch12-Dec-22 6:42 
GeneralRe: Curly braces Pin
OriginalGriff11-Dec-22 23:57
mveOriginalGriff11-Dec-22 23:57 
GeneralRe: Curly braces Pin
pkfox12-Dec-22 0:20
professionalpkfox12-Dec-22 0:20 
GeneralRe: Curly braces Pin
OriginalGriff12-Dec-22 0:30
mveOriginalGriff12-Dec-22 0:30 
GeneralRe: Curly braces Pin
Jörgen Andersson12-Dec-22 3:00
professionalJörgen Andersson12-Dec-22 3:00 
GeneralRe: Curly braces Pin
CPallini12-Dec-22 1:03
mveCPallini12-Dec-22 1:03 
GeneralRe: Curly braces Pin
Slacker00712-Dec-22 1:33
professionalSlacker00712-Dec-22 1:33 
GeneralRe: Curly braces Pin
Mike Hankey12-Dec-22 2:01
mveMike Hankey12-Dec-22 2:01 
GeneralRe: Curly braces Pin
Richard MacCutchan12-Dec-22 2:07
mveRichard MacCutchan12-Dec-22 2:07 
GeneralRe: Curly braces Pin
OriginalGriff12-Dec-22 2:24
mveOriginalGriff12-Dec-22 2:24 
GeneralRe: Curly braces Pin
Ron Anders12-Dec-22 2:27
Ron Anders12-Dec-22 2:27 
GeneralRe: Curly braces Pin
Mircea Neacsu12-Dec-22 2:35
Mircea Neacsu12-Dec-22 2:35 
GeneralRe: Curly braces Pin
MarkTJohnson12-Dec-22 3:48
professionalMarkTJohnson12-Dec-22 3:48 
GeneralRe: Curly braces Pin
Mircea Neacsu12-Dec-22 4:13
Mircea Neacsu12-Dec-22 4:13 
GeneralRe: Curly braces Pin
den2k8812-Dec-22 4:37
professionalden2k8812-Dec-22 4:37 
GeneralRe: Curly braces Pin
PIEBALDconsult12-Dec-22 2:42
mvePIEBALDconsult12-Dec-22 2:42 
GeneralRe: Curly braces Pin
Sanjay K. Gupta12-Dec-22 2:54
professionalSanjay K. Gupta12-Dec-22 2:54 

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.