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 #172571 is a reply to message #172543] Tue, 22 February 2011 00:58 Go to previous message
The Natural Philosoph is currently offline  The Natural Philosoph
Messages: 993
Registered: September 2010
Karma:
Senior Member
Tim Streater wrote:
> In article <iju7sd$9fc$1(at)news(dot)eternal-september(dot)org>,
> Jerry Stuckle <jstucklex(at)attglobal(dot)net> wrote:
>
>> goto is NEVER needed, and SELDOM a good thing to use. It completely
>> violates structured programming practices and causes more problems
>> than it solves.
>
> By and large this is true. With one exception, I haven't used one since
> 1978 when I stopped using FORTRAN.
>
> The exception was when doing some Pascal under RSX-11M. There was no
> "return" statement, so I had to fake one up by putting a 999: label at
> the end of any procedure where I wanted an early return, and then goto 999.
>
Pascal is unmitigated crap. Its a teaching language, not a language that
can be used to do anything useful. It enforces structure to the point
where you have to make a worse choice (the goto) than an early return..


Try creating a union in it as well..

PERSONALLY I find that early returns or breaks make for much easier to
follow code...that strict adherence to if then else..

so

function read_group()
{
while ($post)
{
if ($poster=="stuckle")
continue; //skip irrelevancies
//now process data you are interested in...
..

..
}

}

reads much more eailyily than

function read_group()
{
while ($post)
{
if ($poster!="stuckle")
{
....
....
..
} //endif not stuckle
}

}

Because the latter, can lead to huge nesting and lots of else if else
type constructs.

It also follows the natural economy of thought that says

'if its him, don't even go there' which is the first thing you do.

THEN there may be other reasons to skip or abort. Get the exception
processing done early, simply and quickly, and then the real meat of the
processing is all in a simple block, rather than being interspersed with
exception processing.


That's the difference between academic purism and real life software
engineering: to the purist exception processing is something small that
should not sully the smooth flow of idealised control statements: To the
engineer exception processing is the biggest source of run time errors
and program bugs, and the more its all together and the easier it is to
understand and modify, the more robust the code is likely to be.

If that means saying, or the equivalent of saying

if(condition) go to errror1
...

if (condition) go to error2

and then collecting all the error handling code in one place, where it
can all be reviewed..sod the purists. I'll use goto, continue, return or
whatever the software allows, up to and including setjmp() and
longjmp()..which allowed me to write a piece of code that had functions
nested so deep that the stack groaned under the strain, and instead of
having to check return values all the way up the return chain, I simply
discarded the whole stack, and ended up in a 'master reset with error
message' part of the code..in a time period that was short enough to
keep the employer happy.

Probably the first rule of software engineering is that there is no rule
that cannot and occasionally should be broken, and no rule that is
optimal in every case.

The goal is always clear comprehensible maintainable code that performs
the function for which it was designed: You have to ask yourself, punk,
whether use of a goto or equivalent, gets you nearer to, or further
from, that goal.


Exercises in egotistical cleverness and pedantry can, and should be,
left to usenet postings.
[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: Wed Nov 27 01:34:18 GMT 2024

Total time taken to generate the page: 0.04170 seconds