Returning the null value from a method
This example demonstrates the drawbacks of returning null from your methods. I allays preach to my colleagues that when something is wrong, your method should throw an exception instead of returning a null. But sometimes, especially if I'm writing some tools for myself, because of the laziness, I use the return null too. Few days ago I done that, and very soon I released that it was mistake which caused me unnecessary problems. Story goes like this: There is an initial list of ids and result of a process is a array of fully populated objects. I use that procedure on two places in my tool: for generating RSS file and for generating a view script. The tool is written in Zend Framework, it uses a log file, when exception occurs displays a customized error page and sends a email to me. Initially it was all flawless, but at some point, I released that I'm not able to read data for some of initial ids. So I modified a loading method in something like this: public function loadItem( $...