Everywhere I read constantly rehashes the idea of "never return nulls" but what should I return if not null in the cases where a value cannot be found?
Take the following method
List<Customer> GetCustomerListByRoleID(Guid RoleID) {}
In this case (and in most plural methods) its easy to simply return an empty List<Customer>
if we can't find our value and we're good.
However in the case of a method like
Customer GetCustomerByID(Guid CustomerID) {}
You do not have the luxury of returning an empty array. Infact all you can do is return a New Customer();
but then you have a potentially uninitialized object (which you still need to check for) or null.
So what would be the recommended alternative to returning a null in the singular method?