Re: if statement optimization

new topic     » goto parent     » topic index » view thread      » older message » newer message
frankied said...

If you are just using it in general programming, what is accepted as the best programming practice? eg:

 
if (condition) then 
    -- do a really big operation here 
else 
    -- do a different really big operation here 
end if 
 

or

if (condition) then 
    -- do a really big operation here 
    return 
end if 
 
-- do a different really big operation here 
return 

or is it accepted as purely a matter of personal style

The code below will cause me to want to kick your teeth in.
Thankfully, our geographical dispersion and my usual kind nature would prevent that.

if (condition) then 
    -- any amount of code 
    return 
else 
    -- lots of code 
    return 
end if 
 
-- I prefer 
object result 
if (condition) then 
    -- any amount of code 
    result = "TRUE" 
else 
    -- lots of code 
    result = "FALSE" 
end if 
 
-- print(LOGFILE, result) 
-- Thus allowing for easy debugging. 
return result 

Peace out
Unkmar = "Lucius L. Hilley III"

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu