It is a bad idea? No, you should do what makes sense, and not follow some abstract rule (the likes of which almost never serve all the situations that you will encounter in any case).
One way to avoid trouble is to make sure that the entire logical return function is read as correct English, for example, isEmpty() , userFlaggedExit() or hasContent() . This is different from my usual noun verb constructs, such as updateTables() , deleteAccount() or crashProgram() .
For a function that returns a boolean indicating the success or failure of the function that usually follows this noun verb construct, I usually use something like deleteAccountWorked() or successfulTableUpdate() .
In all of these Boolean cases, I can build an easily readable if :
if (isEmpty (list)) ... if (deleteAccountWorked (user)) ...
And so on.
For non-logical return functions, I still adhere to the agreement that 0 is ok and all other values are incorrect. The use of smart function names usually means that it is obvious.
But keep in mind that is my decision. It may or may not work for other people.
source share