NYCPHP Meetup

NYPHP.org

[nycphp-talk] Question about explicit returns

Michael B Allen ioplex at gmail.com
Fri Jan 11 17:23:35 EST 2008


On 1/11/08, Daniel Convissor <danielc at analysisandsolutions.com> wrote:
> I like returning as soon as possible.  This clarifies exactly what's
> happening.  Otherwise you need to read through the whole function.  Plus
> it dramatically cuts down on the amount of nesting.

I think the nesting helps you understand the code. You know the more
indented you are the deeper the success of the overall operation. If
the nesting get's to it's easy move that block into a new function
without thinking about the logic.

Regarding the number of returns, it's better to minimize the number of
exit points because it simplifies the function contract. If you have
to modify the code later, there are fewer exit points to consider.

Mike

-- 
Michael B Allen
PHP Active Directory SPNEGO SSO
http://www.ioplex.com/



More information about the talk mailing list