A collection of Bad Code Smells in a Catalog form for Developers & Researchers. Code Smell is a typical bad code implementation, and learning these concepts immiedietly makes you a better developer!
I’ve never heard of evading null with a Null object.
This is quite standard, and in fact it’s even a safety feature. C++ introduced nullptr defined as an instance of std::nullptr_t explicitly with this in mind.
Languages that make use of references rather than pointers don’t have this Dualism. C# has nullable references and nullability analysis, and null as a keyword.
Languages that make use of references rather than pointers don’t have this Dualism.
It’s not about references vs pointers. You could easily have a language that allowed “null references” (edit: too much C++; of course many languages allow null references, e.g. Javascript) or one that properly separated null pointers out in the type system.
I agree with your point though, using a special Null value is usually worse than using Option or similar. And nullptr_t doesn’t help with this at all.
Depends on your perspective. It’s convenient to lean on type checking to avoid a whole class of bugs. You can see this either as avoiding NULL or use your type system to flag misuses.
Languages that make use of references rather than pointers don’t have this Dualism. C# has nullable references and nullability analysis, and null as a keyword.
C#'s null keyword matches the monadic approach I mentioned earlier. Nullable types work as a Maybe monad. It’s the same concept shoehorned differently due to the different paths taken by these languages.
as far as I know, C# don’t have proper ergonomic monadic bind as in F# (computation expression), Haskell (do expression), and Ocaml (let*), but I could be wrong.
This is quite standard, and in fact it’s even a safety feature. C++ introduced nullptr defined as an instance of std::nullptr_t explicitly with this in mind.
https://en.cppreference.com/w/cpp/language/nullptr
This approach is also quite basic in monadic types.
With what in mind? Evading
NULL
?Languages that make use of references rather than pointers don’t have this Dualism. C# has nullable references and nullability analysis, and
null
as a keyword.What does your reasoning mean in that context?
It’s not about references vs pointers. You could easily have a language that allowed “null references” (edit: too much C++; of course many languages allow null references, e.g. Javascript) or one that properly separated null pointers out in the type system.
I agree with your point though, using a special
Null
value is usually worse than usingOption
or similar. Andnullptr_t
doesn’t help with this at all.Depends on your perspective. It’s convenient to lean on type checking to avoid a whole class of bugs. You can see this either as avoiding NULL or use your type system to flag misuses.
C#'s
null
keyword matches the monadic approach I mentioned earlier. Nullable types work as aMaybe
monad. It’s the same concept shoehorned differently due to the different paths taken by these languages.as far as I know, C# don’t have proper ergonomic monadic bind as in F# (computation expression), Haskell (do expression), and Ocaml (let*), but I could be wrong.
Correct.