We use a type system and custom, non-primitive types to model ideas and information (whether that is data or behavior).
While representing the null + type union explicitly in code is better than hiding it implicitly, it can't model the same intent that other approaches can because it's a core language feature and not specific to a domain.
I cover this in a series of blog posts about modeling optional and missing data in code (C#).
Even with C#'s improved pattern matching, Maybe can provide a better dev experience than null by being more declarative than the imperative handling of null.
3 comments on this page
Dick Baker
extra info on NRT attributes AllowNull,DisallowNull, MaybeNull,NotNull etc here
https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/attributes/nullable-analysis
which might help devs with pre/post condition specs.
BTW for the $1B mistake see the Tony Hoare links
https://en.wikipedia.org/wiki/Tony_Hoare
https://www.infoq.com/presentations/Null-References-The-Billion-Dollar-Mistake-Tony-Hoare/
Sean G. Wright
Great points!
We use a type system and custom, non-primitive types to model ideas and information (whether that is data or behavior).
While representing the null + type union explicitly in code is better than hiding it implicitly, it can't model the same intent that other approaches can because it's a core language feature and not specific to a domain.
I cover this in a series of blog posts about modeling optional and missing data in code (C#).
https://dev.to/seangwright/kentico-xperience-design-patterns-modeling-missing-data-the-maybe-monad-2c7i
Even with C#'s improved pattern matching, Maybe can provide a better dev experience than null by being more declarative than the imperative handling of null.
Nice post!
Nick Hodges
From your mouth to God's ear.