Why is a null reconfiguration not recommended? The idea is that if the return type of the function is T , you always get one object of type T , and null definitely not something of type T , even null objects of type T
In the case of getCustomers() you get a List<Customer> , from 0 to n Customer objects.
In the case of getCustomer() you need 0 or 1 Customer objects. In Haskell, you get ADT and Maybe for this, in Scala you have the case and Option classes. What can you use in c #? Well, there Maybe the implementation is in C # , it's really just inside.
With Maybe<Customer> getCustomer() you are guaranteed not to pass its result as a null value instead of a Customer value. You are clearly warned: you can get the Client or not the Client.
Why Maybe works better than null ? Because Maybe is a monad with a sound mathematical foundation, and null is not. List also a monad, which makes it so convenient. With the right approach, monads can be combined beautifully , so you don't need to check HasValue everywhere. With null you are stuck in a nested C if style for each function result.
Exceptions are also a monad! This is why the other answers (correctly) suggest throwing an exception. With exceptions, you even get another nice thing that is characteristic of functional programming, namely pattern matching (in catch ).
source share