in reply to Efficiency & Maintenance: if/elsif or Other Dispatch Method
This has come up before; but I can tell you right off the bat your code is more complicated than it needs to be. In the following:
You don't need the second condition in the second case (<= 97) because it will always be true if that test is reached, due to the preceding test.if ($outcome > 97) { $rv .= "99"; } elsif ( ($outcome > 93) && ($outcome <= 97) )
if ( $outcome > 97 ) { $rv .= "99"; } elsif ( $outcome > 93 ) { $rv .= "95"; } elsif ( $outcome > 85 ) { $rv .= "90"; } elsif ( $outcome > 75 ) { $rv .= "80"; } elsif ( $outcome > 65 ) { $rv .= "70"; } elsif ( $outcome > 55 ) { $rv .= "60"; } elsif ( $outcome > 45 ) { $rv .= "50"; } elsif ( $outcome > 35 ) { $rv .= "40"; } elsif ( $outcome > 25 ) { $rv .= "30"; } elsif ( $outcome > 15 ) { $rv .= "20"; } elsif ( $outcome > 7 ) { $rv .= "10"; } elsif ( $outcome > 3 ) { $rv .= "05"; } elsif ( $outcome > 0 ) { $rv .= "00"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Efficiency & Maintenance: if/elsif or Other Dispatch Method
by Herkum (Parson) on Dec 01, 2006 at 21:45 UTC |