4 ms·
Agreed on most counts. However the Rule 3: What you don’t disambiguate now, you debug later it is so hard to follow. I am guilty of using -1 so many times on
by sireat 5y ago
Agreed on most counts.
However the Rule 3: What you don’t disambiguate now, you debug later it is so hard to follow.
I am guilty of using -1 so many times on numeric returns
. The alternatives Null,None,nil types break the type signature for many languages.
So that leads to constructs like Option(None) in Scala
Raising exception (if the language allows it) does not seem right either if returning a missing/unexpected result is "legal" just rare.
Similarly on string return signatures I've liked to use empty strings on failing conditions.
When some object is expected to be returned by function I've liked to return that object with default construction (ie returning a blank Dog object when no proper Dog is found).