NYCPHP Meetup

NYPHP.org

[nycphp-talk] Question about explicit returns

tedd tedd at sperling.com
Sat Jan 12 10:52:40 EST 2008


At 12:45 PM -0500 1/11/08, Tod Dailey wrote:
>The validity of one of my coding practices that I've used for awhile 
>has recently come under question. I've tried to listen to arguments 
>on both sides, and there seems to be good points on both ends, but 
>my question still hasn't been answered to my satisfaction.
>
>When I'm writing a function that returns a Boolean that indicates 
>that the given process failed or succeeded, I declare the Boolean as 
>a variable at the top of the function. I feel that this makes the 
>code easier to read whenever/if-ever I need to come back and add 
>further logic conditions to that function. When I come back to the 
>function, I have a short list of accept by exception where I 
>more-or-less just need to find the point that I return true to 
>understand the function. Verse inline returns, such as "if 
>($condition !== true) return false;" that builds a list of failure 
>by exception. It may just be in my head that the first method is 
>easier to read, but that's why I'm asking for input/options. Here 
>are two examples. They should both return the same value, but by 
>different means.

Number 1. One way into and out of a function.

Cheers,

tedd
-- 
-------
http://sperling.com  http://ancientstones.com  http://earthstones.com



More information about the talk mailing list