Click here to Skip to main content
15,886,963 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.

 
GeneralRe: if else Style Pin
0x01AA26-Jan-24 8:09
mve0x01AA26-Jan-24 8:09 
GeneralRe: if else Style Pin
trønderen26-Jan-24 8:29
trønderen26-Jan-24 8:29 
GeneralRe: if else Style Pin
0x01AA26-Jan-24 9:32
mve0x01AA26-Jan-24 9:32 
GeneralRe: if else Style Pin
Gary R. Wheeler26-Jan-24 13:12
Gary R. Wheeler26-Jan-24 13:12 
GeneralRe: if else Style Pin
BernardIE531726-Jan-24 13:34
BernardIE531726-Jan-24 13:34 
AnswerRe: if else Style Pin
Ravi Bhavnani26-Jan-24 20:53
professionalRavi Bhavnani26-Jan-24 20:53 
GeneralRe: if else Style Pin
trønderen27-Jan-24 9:05
trønderen27-Jan-24 9:05 
GeneralRe: if else Style Pin
BernardIE531727-Jan-24 10:24
BernardIE531727-Jan-24 10:24 
I was recently influenced by an article recommending nesting be minimized. There are many such articles also here on this site. I also learned to detect and return from error cases as soon as possible if not immediately.

re/ braces and indentation etc. it is my opinion we all process visual information in our own way. My own main rule is to write / format in a manner which is pleasing to the eye exempli gratia as two specimens (not snippets as they were obviously not taken out from a code base) below.

re/ 1st specimen I prefer as below as I find your preferred style requiring greater cognitive load as there is simply more stuff to process but as stated we all process differently. Also there is the matter of screen real estate.

I find it helpful for braces to align. Also the IDE provides a vertical line of dots connecting same which I find quite helpful even rely on.
C++
if (condtion) statement;
next_statement;
if(condition)
{
.  statement;
.  statement;
.  statement;
}
I do not understand the 2nd discussion. Why not merely write
if (!(argX > MaxXvalue|| argY < 0.0 || argZ == null))
{ 
   statement;
   statement;
}
I agree w/ your final discussion. The purist style is a mess.

In closing I have never seen do {} while (false) I now realize it is identical to if(true) {}. Do you find this style more logical or pleasing to the eye.

modified 27-Jan-24 16:41pm.

GeneralRe: if else Style Pin
trønderen27-Jan-24 11:44
trønderen27-Jan-24 11:44 
GeneralRe: if else Style Pin
BernardIE531727-Jan-24 12:16
BernardIE531727-Jan-24 12:16 
GeneralRe: if else Style Pin
trønderen27-Jan-24 14:32
trønderen27-Jan-24 14:32 
GeneralRe: if else Style Pin
BernardIE531727-Jan-24 14:42
BernardIE531727-Jan-24 14:42 
GeneralRe: if else Style Pin
BernardIE531727-Jan-24 19:16
BernardIE531727-Jan-24 19:16 
GeneralRe: if else Style Pin
BernardIE531727-Jan-24 11:59
BernardIE531727-Jan-24 11:59 
GeneralRe: if else Style Pin
Ravi Bhavnani28-Jan-24 16:52
professionalRavi Bhavnani28-Jan-24 16:52 
GeneralRe: if else Style Pin
Iacopo Vettori28-Jan-24 23:47
Iacopo Vettori28-Jan-24 23:47 
GeneralRe: if else Style Pin
Peter Kelley 202128-Jan-24 23:58
Peter Kelley 202128-Jan-24 23:58 
GeneralRe: if else Style Pin
John Wellbelove29-Jan-24 1:29
John Wellbelove29-Jan-24 1:29 
GeneralRe: if else Style Pin
MikeCO1029-Jan-24 1:42
MikeCO1029-Jan-24 1:42 
GeneralRe: if else Style Pin
Matt Bond29-Jan-24 2:49
Matt Bond29-Jan-24 2:49 
GeneralRe: if else Style Pin
jschell29-Jan-24 5:22
jschell29-Jan-24 5:22 
GeneralRe: if else Style Pin
Alister Morton30-Jan-24 23:46
Alister Morton30-Jan-24 23:46 
GeneralRe: if else Style Pin
Stacy Dudovitz29-Jan-24 13:56
professionalStacy Dudovitz29-Jan-24 13:56 
GeneralRe: if else Style Pin
jschell30-Jan-24 4:40
jschell30-Jan-24 4:40 
GeneralRe: if else Style Pin
Stacy Dudovitz30-Jan-24 10:38
professionalStacy Dudovitz30-Jan-24 10:38 

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.