DEV Community

Discussion on: Code Smell 24 - Boolean Coercions

 
netch80 profile image
Valentin Nechayev

Sounds easy. It is easy

"For every complex problem there is an answer that is clear, simple, and wrong." (c)
This is exactly the case you show here.

Thread Thread
 
mcsee profile image
Maxi Contieri

Ok. I respect your opinion

Thread Thread
 
netch80 profile image
Valentin Nechayev

I respect your opinion

Thanks:))
I'd add that Hoare is too self-blaming. At the moment he devised NULL, it was good solution. As always, remedy renders into poison only in excessive amounts. What we really needed is strict non-NULL guarantee at compiler level - and, well, this is what is added to much part of newer languages and tools; and, where we are sure any NULL is not allowed, this shall be marked, to allow checking. For God's sake, developer tools are now powerful enough.
The more problem I've faced once is that the whole set of "undefined" and "null" is not enough in some cases. This was a monitoring tool where we had to invent multiple cases as "sensor is absent", "sensor is unreachable" and "sensor is failing". This doesn't fit into traditional approaches with a single special value, but a language which allows algebraic types nicely fit here. Over recent ones, nearly any do (with different efficiency).