Good Coding with ElseIF
#8
It's a matter of legibility more than logic flow. The more nested if...thens the harder it will be to track the if...efseif...thens as the code grows in complexity.

Code: (Select All)
x = 3: y = 5

'this block is easier to read
If x > 5 Then
    Print "x"; x
Else
    If y > 2 Then
        Print "Y"; y
    Else
        Print "X+Y"; x + y
    End If
End If

'this block isn't as easy to read but will produce the same results as the one above
If x > 5 Then
    Print "x"; x
ElseIf y > 2 Then
    Print "Y"; y
Else    
    Print "X+Y"; x + y
End If
Reply


Messages In This Thread
Good Coding with ElseIF - by Dimster - 05-04-2023, 04:11 PM
RE: Good Coding with ElseIF - by mnrvovrfc - 05-04-2023, 04:45 PM
RE: Good Coding with ElseIF - by Dimster - 05-04-2023, 07:22 PM
RE: Good Coding with ElseIF - by mnrvovrfc - 05-04-2023, 09:12 PM
RE: Good Coding with ElseIF - by James D Jarvis - 05-04-2023, 09:23 PM
RE: Good Coding with ElseIF - by TerryRitchie - 05-04-2023, 09:51 PM
RE: Good Coding with ElseIF - by James D Jarvis - 05-05-2023, 01:39 AM
RE: Good Coding with ElseIF - by mnrvovrfc - 05-04-2023, 10:09 PM
RE: Good Coding with ElseIF - by James D Jarvis - 05-05-2023, 01:35 AM
RE: Good Coding with ElseIF - by Dimster - 05-05-2023, 01:03 PM
RE: Good Coding with ElseIF - by bplus - 05-05-2023, 05:38 PM
RE: Good Coding with ElseIF - by Dimster - 05-05-2023, 08:11 PM
RE: Good Coding with ElseIF - by bplus - 05-05-2023, 08:37 PM



Users browsing this thread: 1 Guest(s)