Click here to Skip to main content
15,887,313 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
honey the codewitch26-Jan-24 8:13
mvahoney the codewitch26-Jan-24 8:13 
GeneralRe: if else Style Pin
Graeme_Grant26-Jan-24 20:32
mvaGraeme_Grant26-Jan-24 20:32 
GeneralRe: if else Style Pin
k505426-Jan-24 5:51
mvek505426-Jan-24 5:51 
GeneralRe: if else Style Pin
charlieg26-Jan-24 9:58
charlieg26-Jan-24 9:58 
GeneralRe: if else Style Pin
trønderen26-Jan-24 10:21
trønderen26-Jan-24 10:21 
GeneralRe: if else Style Pin
charlieg28-Jan-24 2:27
charlieg28-Jan-24 2:27 
GeneralRe: if else Style Pin
Norm Powroz29-Jan-24 5:36
Norm Powroz29-Jan-24 5:36 
GeneralRe: if else Style Pin
trønderen29-Jan-24 10:38
trønderen29-Jan-24 10:38 
Norm Powroz wrote:
Having the braces on separate lines makes it so much easier to determine where the then/else clauses begin and end.
You have indentation for that, don't you?

If you indent neither of the braces, they do not enforce the indentation, but blurs both the indentation and the keyword causing the indentation. If you indent both, the keyword is 'revealed'. And the block is extended by two two lines, making it more prominent.

I think that making 'the indenting keyword' more visible (by avoiding the blurring opening brace immediately below it) is a good thing. Indenting before the opening brace is logically inconsistent - so the brace should be un-indented, at the line of the if / while / ... . Also, when you read e.g. an if, and the line ends abruptly, with no explanation, you should rather include the brace to indicate: There is an explanation - this brace tells that a block is following!

The closing brace on a separate indented line ensures that the indented block is at least two lines long. That should be enough for everybody, to make sure that the block is easily identified.

I think un-indented braces blur the indented block, rather than enforcing it as it should.

Religious freedom is the freedom to say that two plus two make five.

GeneralRe: if else Style Pin
Jörgen Andersson25-Jan-24 21:20
professionalJörgen Andersson25-Jan-24 21:20 
GeneralRe: if else Style Pin
BernardIE531725-Jan-24 21:39
BernardIE531725-Jan-24 21:39 
GeneralRe: if else Style Pin
Richard MacCutchan25-Jan-24 22:22
mveRichard MacCutchan25-Jan-24 22:22 
GeneralRe: if else Style Pin
Amarnath S25-Jan-24 23:38
professionalAmarnath S25-Jan-24 23:38 
GeneralRe: if else Style Pin
BernardIE531725-Jan-24 23:47
BernardIE531725-Jan-24 23:47 
GeneralRe: if else Style Pin
trønderen26-Jan-24 0:05
trønderen26-Jan-24 0:05 
GeneralRe: if else Style Pin
BernardIE531726-Jan-24 1:04
BernardIE531726-Jan-24 1:04 
GeneralRe: if else Style Pin
trønderen26-Jan-24 1:57
trønderen26-Jan-24 1:57 
GeneralRe: if else Style Pin
Richard Andrew x6426-Jan-24 5:03
professionalRichard Andrew x6426-Jan-24 5:03 
GeneralRe: if else Style Pin
trønderen26-Jan-24 5:19
trønderen26-Jan-24 5:19 
GeneralRe: if else Style Pin
jschell26-Jan-24 5:49
jschell26-Jan-24 5:49 
GeneralRe: if else Style Pin
PIEBALDconsult27-Jan-24 7:17
mvePIEBALDconsult27-Jan-24 7:17 
GeneralRe: if else Style Pin
Matt Bond29-Jan-24 3:02
Matt Bond29-Jan-24 3:02 
GeneralRe: if else Style Pin
Maximilien26-Jan-24 1:47
Maximilien26-Jan-24 1:47 
GeneralRe: if else Style Pin
BernardIE531726-Jan-24 2:02
BernardIE531726-Jan-24 2:02 
GeneralRe: if else Style Pin
trønderen26-Jan-24 2:06
trønderen26-Jan-24 2:06 
GeneralRe: if else Style Pin
trønderen26-Jan-24 2:26
trønderen26-Jan-24 2:26 

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.