Re: Long Live GOTO
| From: | Jim Giner | Date: | Mon, 06 Feb 2012 17:56:42 +0000 |
| Subject: | Re: Long Live GOTO | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-316487@lists.php.net to get a copy of this message | ||
"Robert Cummings" <robert@interjinn.com> wrote in message
news:4F30086A.6080904@interjinn.com...
1) deal with the trivial and error cases first
>
> Some say you should never return early from a function... I too think that
> early returns can improve the readability of a function--
> especially if they are short snippets of logic that clearly indicate the
> reason for an early exit (usually edge case constraints).
>
> :)
>
> Cheers,
> Rob.
> --
I agree. Using multiple returns is merely a goto. Maintenance of that
function must then take into account those "multiple paths" in that function
as the changes are added. Modifying the original function to remove the
returns so that *all* flows will encounter the 'new' code can cause problems
if today's author misses something in the logical path of the process(es).