Thread: Curly brackets!
View Single Post
Old 05-06-2009, 01:57 PM   #12 (permalink)
allworknoplay
The Gregarious
 
allworknoplay's Avatar
 
Join Date: Feb 2009
Location: New York
Posts: 645
Thanks: 64
allworknoplay is on a distinguished road
Default

wow WH:

You are quite thorough....you and Salathe...

Anyways, do you think there are any performance benefits of including the inclusions first?
Or is this just simply just a preferable method that utilizes "continue" which I normally don't use in my everyday tasks...but I can see how it is useful in your example..

Also, it's probably just preference with a mixture of good coding practice, but in your other example you have this:

PHP Code:
function doThisAndThat($bTrueOrFalse)
{
    if (
$bTrueOrFalse)
    {
        return 
'It is true';
    }
   
    
/* If the above is true we can be sure it's NOT true here. */
    
return 'It is false';

Would you ever do this or think this looks cleaner?
I know how much you hate using "else"...


PHP Code:
function doThisAndThat($bTrueOrFalse)
{
    if (
$bTrueOrFalse) return 'It is true';
    else return 
'It is false';


EDIT: I see you added more after I posted which kinda answers my question.

Quote:
The underlining assumption behind this way of working is that the chunk of code required for processing exclusions will be smaller than the code for processing inclusions.
allworknoplay is offline  
Reply With Quote