A "getListOfThings" function should return an empty list if there is
nothing to get, not false.
As Bernhard already states one should try to stick with a single
return type to avoid type conversion Abracadabra.
On 04-02-15 13:21, Robin McCorkell
wrote:
Hi,
I feel as though we are in limbo with regards to
exceptions. Some code uses exceptions to report an error, while
others return null or false. I suspect this is one of the
reasons why these situations have occurred.
It is my opinion that a function should only return
values that make sense. If a function is named getUser, it
should only return the user, and if it can't that is clearly an
error situation where an exception should be thrown. On the
other hand, a function like getListOfThings could viably return
false if there is nothing to get (unless those things are
expected to be there!).
A change to a fully exception based system won't
happen overnight, but it'd be nice to see it promoted more in
the code base.
Just my thoughts,
Robin McCorkell
|
_______________________________________________
Devel mailing list
[email protected]
http://mailman.owncloud.org/mailman/listinfo/devel