Optional types are where it's at, and there's some prebuilt ones that are more or less free to use in terms of complexity.
Rearchitecting your entire application to deny the fact that nulls exist as a valid value strikes me as basically the nuclear option when compared to dealing with them head on.
Grumpy old fart that throws up a little every time he sees someone being passionate about some javascript lib. Tech agnostic. If it bleeds, I can kill -9 it.
It is not necessarily about nulls, but what to do in the absence of a value. You can often find multiple types of these null classes to cover different cases. And it does mean you have to rearchitect anything. For instance, when designing a Card component in a React application, that was dealt a User object, we assumed it would always exist. Suddenly, it was potentially optional, but that would imply changing user: User to user: User | undefined through multiple levels. Simply creating a NullUser that was returned at the top level selector function allowed us to make 0 (zero) changes further down.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Optional types are where it's at, and there's some prebuilt ones that are more or less free to use in terms of complexity.
Rearchitecting your entire application to deny the fact that nulls exist as a valid value strikes me as basically the nuclear option when compared to dealing with them head on.
It is not necessarily about
null
s, but what to do in the absence of a value. You can often find multiple types of these null classes to cover different cases. And it does mean you have to rearchitect anything. For instance, when designing a Card component in a React application, that was dealt aUser
object, we assumed it would always exist. Suddenly, it was potentially optional, but that would imply changinguser: User
touser: User | undefined
through multiple levels. Simply creating aNullUser
that was returned at the top level selector function allowed us to make 0 (zero) changes further down.