DEV Community

Discussion on: Code Smell 145 - Short Circuit Hack

Collapse
 
mcsee profile image
Maxi Contieri • Edited

Null is the worst code smell

And optional chaining, IMHO hids this antipattern.
I've written a smell on optional chaining. I will publish it in the following weeks

hackernoon.com/null-the-billion-do...

And optional chaining is another code smell

Collapse
 
larsejaas profile image
Lars Ejaas

But we are not always writing the data or code with null ourselves.

One example: Auto-generated types made with GraphQL Code Generator.
We still need to be able to handle null.
Null does indeed make sense if you do not know if data will return empty.

Thread Thread
 
mcsee profile image
Maxi Contieri

Of course
In case null is beyond your own control you need to deal with it

That is why it is the billion dollar mistake

We must be mature enough to avoid creating NEW nulls

Thread Thread
 
larsejaas profile image
Lars Ejaas

Yeah, that makes sense 😄