Eddie Peloke's Blog

Saturday, July 09, 2005

Let's play catch!

Yesterday, I had a chance to play a bit with exceptions. I have used them before in java but never in php. While I only have the basics in my code now, I am excited about their potential. In the past, when I wrote a method, I would just return false on any type of error. The method did contain error checking but ultimately would just send back false to let the calling code know there was a problem. This works ok but causes the calling code to handle some level of error checking and doesn't really allow the caller to know what is going on......sort of like going to the doctor and simply hearing..."Yep, there's a problem" and then having him walk out the door. I am hoping that exceptions will allow me to better control the error checking and keep it closer to the methods causing the trouble....then again I have onlly begun to play and may hate exceptions tomorrow.

Now to go play catch with my code.

2 Comments:

  • hey Eddie,
    I'm FINALLY getting to upgrade our package to php5 and exceptions are one of those things I'm definately looking forward to using. I'm finding php5 not to be all that backwards compatible. I have weeks if not months ahead of me bringing our package to be php5 ready. :(

    Jim Plush
    http://www.litfuel.net/plush

    By Anonymous Anonymous, at 9:22 AM  

  • We had few problems moving up to php5. A while back I upgraded my local dev server to php5 and moved the code over to see what would break. We really only had a few places where it complained....just a few issues such as having two class variables with the same name etc. but nothing major. When it came time for us to try it live, we upgraded our dev servers to php5 and I believe within a few weeks we were live on production. Except for new classes that have been created after the upgrade, all of our old code is still using php4 syntax and php5 seems fine with it.

    What problems are you having?

    PHP5's OOP improvements are nice...it is nice to be able to create a class now and use exceptions, public/ private methods, etc.

    By Blogger Eddie, at 4:19 PM  

Post a Comment

<< Home