FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » terminate a PHP script
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: terminate a PHP script [message #172553 is a reply to message #172548] Mon, 21 February 2011 19:44 Go to previous messageGo to previous message
Tim Streater is currently offline  Tim Streater
Messages: 328
Registered: September 2010
Karma:
Senior Member
In article <slrnim5e3u(dot)2mh(dot)hellsop(at)nibelheim(dot)ninehells(dot)com>,
"Peter H. Coffin" <hellsop(at)ninehells(dot)com> wrote:

> On Mon, 21 Feb 2011 18:50:39 +0000, Tim Streater wrote:
>> Because of the incredible convolution and depth of nested if/then/else
>> you can get to. If I have (as it might be) a function that's scanning a
>> string looking for and obtaining options and their values for some
>> command previously scanned off the string, and I detect an error, I want
>> to set an error code and exit right there. I don't want any subsequent
>> maintainer to have to intuit that, in fact, from this point on nested
>> 15-deep in else clauses, no more code is executed for that path through
>> the function.
>>
>> That way I rarely get more than 3-deep in if/then/else. To me, it's all
>> about readbility.
>
> *grin* for me, it's all about comprehesibility. If you don't like how
> deep you're nesting, maybe you need to break something out into a
> function instead....

Of course; I agree that if you're 15 levels deep you've got a design
problem. But that's my point. Early exit helps avoid that so you can
focus on the next thing.

I have seen this sort of code, btw. Functions hundreds of lines long
with more hundreds separating "if" from the corresponding "else". I
suppose the writer could follow it, but then he was IQ200.

--
Tim

"That excessive bail ought not to be required, nor excessive fines imposed,
nor cruel and unusual punishments inflicted" -- Bill of Rights 1689
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Extralight browser-webserver communication via cookies (+)
Next Topic: Storing multiple character set types (or a representation of em) in a table column
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 23:34:26 GMT 2024

Total time taken to generate the page: 0.04291 seconds