NYCPHP Meetup

NYPHP.org

[nycphp-talk] If/else vs Try/catch

Ben Sgro (ProjectSkyLine) ben at projectskyline.com
Wed Nov 28 16:18:06 EST 2007


Hello John,

Good point. I started realize that this method
pushes the responsilibty for error handling up the chain,
which is something I sometimes struggle with
with if/else.

Once I really start writing some code, I'll be able
to see the benefits, as I'm sure I'll be happy with
these technique as well.

- Ben

----- Original Message ----- 
From: "John Zabroski" <johnzabroski at yahoo.com>
To: "NYPHP Talk" <talk at lists.nyphp.org>
Sent: Wednesday, November 28, 2007 3:56 PM
Subject: Re: [nycphp-talk] If/else vs Try/catch


>
> --- csnyder <chsnyder at gmail.com> wrote:
>>
>> Error handling doesn't need to be part of your
>> program logic anymore.
>>
>> -- 
>> Chris Snyder
>> http://chxo.com/
>
> Be careful saying that, especially to a newbie.  While
> experienced programmers presumably understand
> statements other experienced programmers like you
> make, a newbie might not understand an overly general
> statement like the one you just made.  I understand
> what you are saying, but it is a gross simplification
> for someone needing deep, penetrating understanding of
> a new concept.
>
> Error handling does not just magically disappear from
> program logic, even if you use try/catch. In fact, it
> is quite easy for code to fall prey to a Split Cleaner
> bug pattern when using exception handling.  Ken Downs
> posted a "gotcha" with exception handling already.
>
> Try/catch does not eliminate error handling from
> program logic.  Instead, it does only what it was
> originally designed to do: let the caller of the
> function determine how to respond to a failure
> condition.  Explicitly, the caller has greater
> responsibility in the call chain, because the calling
> function has more contextual knowledge and should be
> more able to recover from failure gracefully.
>
>
> 
> ____________________________________________________________________________________
> Be a better sports nut!  Let your teams follow you
> with Yahoo Mobile. Try it now. 
> http://mobile.yahoo.com/sports;_ylt=At9_qDKvtAbMuh1G1SQtBI7ntAcJ
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php 




More information about the talk mailing list