Why I Never Null-Check Parameters

Writing code to make sure that input parameters are not null does not make Java code "safer;" it’s exactly the opposite — it makes code less readable and less safe.

Code With Null-Checks Is Less Readable

It would be difficult to argue that null-checks are attractive. Most of the time, it’s just boilerplate code, which contributes nothing to the "logic" of the method. It is a purely technical construct. Like this one:

Source de l’article sur DZONE

0 réponses

Laisser un commentaire

Participez-vous à la discussion?
N'hésitez pas à contribuer!

Laisser un commentaire

Votre adresse de messagerie ne sera pas publiée.