Re: MySQL class. Thoughts?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 21, 2009 at 10:00:53PM +0100, Jochem Maas wrote:

> Jay Moore schreef:
> >
> >> I know it's very OO-y to use exceptions, but I hate them. They're like
> >> setjmp/longjmp calls in C, and they're a really headache to deal with.
> >> If you don't use default or predone handlers, you have to put all kinds
> >> of try/catch blocks around everything. They make for non-linear
> >> execution, and I prefer my code to execute in a linear fashion.
> >>
> >> Paul
> >>
> >
> > My thoughts exactly.  What do I gain by using a try/catch that I lose by
> > using if/else or similar?
> 
> you use them not for control flow, but for deferring exceptional application
> states, which you can then handle in a small number of places as opposed
> to scattering the error handling of unlikely events in all sorts of
> disparate places.
> 
> there is an art to using them, they compliment 'traditional' error handling,
> and I agree they can hinder if used badly.

I understand, but then it comes down to how you define an "exceptional
application state". If I build a date class that throws exceptions, it's
very OO-y, but a waste of my programmer time. I could just as easily
build an error checker into the class and use that to check for errors.
Generally speaking, my next step is going to be to display the page
again and tell the user to retype the date properly anyway.

There are reasons to use setjmp and longjmp in C as well, but I only
ever used them once, and later ripped out that code.

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux