DEV Community

Discussion on: Unhealthy Code: Null Checks Everywhere!

Collapse
 
olvnikon profile image
Vladimir

What if a property or a property of a property is still optional? E.g., user.address.zipCode. There is a proposal to avoid intermediate checks. user.address?.zipCode. However, zipCode is still nullable. Having null/undefined in any place is code smell and potential hole in the application. That's why it is always better to have a not null result. The problem is persistent not only in OOP but in FP as well, however, FP has a good way to handle it. Instead of working with null it provides you None.