Miguel has over 10 years of experience with Microsoft Technologies. Specialized with many things in the Microsoft ecosystem, including C#, F#, and Azure
I use Language-ext (github.com/louthy/language-ext) in all my projects now. It has made our code more readable and less error-prone using Either and Option in all our method's signatures. Doing so makes the returns very explicit for the caller instead of Exceptions and null which are implicit.
Option<int> -> Returns a int or not. e.g. GetById Either<string, int> -> Returns a int in case of success and string in case of failure with the error message
Structs are a different story. Why would I use Option<int> when Nullable<int> (or int?) is an option? It clearly expresses that it may not return a value.
I use Language-ext (github.com/louthy/language-ext) in all my projects now. It has made our code more readable and less error-prone using
EitherandOptionin all our method's signatures. Doing so makes the returns very explicit for the caller instead ofExceptionsandnullwhich are implicit.Option<int>-> Returns aintor not. e.g.GetByIdEither<string, int>-> Returns aintin case of success andstringin case of failure with the error messageStructs are a different story. Why would I use
Option<int>whenNullable<int>(orint?) is an option? It clearly expresses that it may not return a value.LanguageExt will force you to deal with null values,
int?won't. Also lots of extension methods to deal with optional types.