Wednesday, March 26, 2008

Some PHP 5 Best Practices: Exceptions

xml.lt: Blog: PHP 5 features: Exceptions: "Exceptions should never be used as normal program flow. If removing all exception handling logic (try-catch statements) from the program, the remaining code should represent the 'One True Path' -- the flow that would be executed in the absence of errors.
This requirement is equivalent to requiring that exceptions be thrown only on error conditions, and never in normal program states."


  • This sounds good on the surface, but life is not so black and white. What about user login... is handling a wrong password an error or normal flow? I could make either argument pretty convincingly.

    By Blogger David, at 11:17 a.m.  

Post a Comment

<< Home