@GinoMan said in Check for all zeros:
@djls45 said in Check for all zeros:
So the caller provided the format and the DateTime was nullable. Did the function ever return null or did it just return a nullable object? Does it always return a new DateTime?() if it can't parse the string or only for empty and zero filled strings?
IIRC their chief architect had read an article on some pattern (Null Object Pattern?) where functions would never
return null. Instead they would return an uninitialized object so that the calling function could never crash with a NullReferenceException.
I can imagine it's a good idea to return an empty
IEnumerable instead of
null so that writing a loop is easier... but for other cases, just let the calling function do a proper check on
The team in India felt that having the application blow up in the face of the customer was not good for their reputation. Writing unmaintainable code that is expensive to extend on the other hand is less visible. That's a problem for another day.