Click here to Skip to main content
15,887,214 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
Richard MacCutchan26-Jan-24 3:19
mveRichard MacCutchan26-Jan-24 3:19 
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 
Wholeheartedly agree!

Having the braces on separate lines makes it so much easier to determine where the then/else clauses begin and end. Lining them up vertically at each indentation level also means you can easily see what goes with what, such as:

if (expression)
{
// then result
if (other condition)
{
// Other condition then result
}
else
{
// other condition else result
}
}
else
{
// else result
}

I really hate code that puts all the opening braces on the if (expression) line, or the "else" line. Programmers who don't believe in clarity of their code should be banned from the practice.

Don't forget -- comments can also help a lot in improving clarity.
GeneralRe: if else Style Pin
trønderen29-Jan-24 10:38
trønderen29-Jan-24 10:38 
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 

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.