Dee Ayy wrote:

> It's for better code.
> 
> Personally, I'm trying to get away from multiple return/exit paths,

Hurray for you :)

[..]

> At a minimum, I would change this:
> 
> 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';
> }
> 
> to this:
> 
> function doThisAndThat($bTrueOrFalse) {
>    $return_value = 'It is false';   // Set your default state here.
>     if ($bTrueOrFalse)
>     {
>         $return_value = 'It is true';  //  Update state.
>     }
> 
>     return $return_value; // Only 1 exit path.
> }

Yes. This is also perfectly compatible with the diagramming method I 
mentioned previously.

> I've also noticed that, for the most part, PHP itself codes
> functions_or_variables_like_this, while coming from Java, my PHP code
> looksLikeThis.
> 
> Slightly more readable for say do_www_design versus doWWWDesign versus
> do_wwwd_esign for those times when you run into such names.

It shouldn't matter much which style you use, as long as you are 
reasonably consistent in it.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to